aboutsummaryrefslogtreecommitdiff
path: root/Jenkinsfile
diff options
context:
space:
mode:
authorChristian Segundo2023-09-16 10:44:22 +0200
committerChristian Segundo2023-09-16 12:30:18 +0200
commit447718be411781ae06308299e67dfc2b6bf13695 (patch)
tree0a1d348e440109958f5d4886ec5347c73cbfcea4 /Jenkinsfile
parente76c12f98fbce4870422790161876163335fc809 (diff)
downloadtransmission-hacks-447718be411781ae06308299e67dfc2b6bf13695.tar.gz
sorry
Diffstat (limited to 'Jenkinsfile')
-rw-r--r--Jenkinsfile69
1 files changed, 69 insertions, 0 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..3dbb750
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,69 @@
+pipeline {
+ agent { label 'rootful' }
+ options { parallelsAlwaysFailFast() }
+ environment {
+ PROJECT = 'transmission-hacks'
+ IMAGE_NAME = "docker.io/chn2guevara/$PROJECT"
+ }
+ stages {
+ stage('Prepare') {
+ steps { sh 'apt-get update && apt-get install -y podman buildah' }
+ }
+ stage('Manifest') {
+ steps { sh "buildah manifest create $PROJECT" }
+ }
+ stage('Build') {
+ parallel {
+ stage('arm64/v8') {
+ steps {
+ sh"""
+ buildah build --arch arm64/v8 --network host \
+ --tag $IMAGE_NAME:latest --manifest $PROJECT .
+ """
+ }
+ }
+ stage('amd64') {
+ steps {
+ sh"""
+ buildah build --arch amd64 --network host \
+ --tag $IMAGE_NAME:latest --manifest $PROJECT .
+ """
+ }
+ }
+ }
+ }
+ stage('docker.io login') {
+ when { branch 'master' }
+ steps {
+ withCredentials([string(
+ credentialsId: 'dockerhub-personal',
+ variable: 'CREDENTIALS')
+ ]) {
+ sh '''#!/bin/bash
+ IFS=" " read -r username password <<<"$CREDENTIALS"
+ podman login docker.io \
+ --username "$username" \
+ --password-stdin <<< "$password"
+ '''
+ }
+ }
+ }
+ stage('Push latest') {
+ when { branch 'master' }
+ steps { sh "buildah manifest push --all $PROJECT docker://$IMAGE_NAME:latest" }
+ }
+ stage('Push tag') {
+ when { branch 'master' }
+ steps {
+ script {
+ tag = sh(
+ returnStdout: true,
+ script: "git name-rev --name-only --tags HEAD"
+ ).trim()
+ if(tag == 'undefined') { return }
+ sh "buildah manifest push --all $PROJECT docker://$IMAGE_NAME:$tag"
+ }
+ }
+ }
+ }
+}