diff options
author | Christian Segundo | 2023-09-16 10:44:22 +0200 |
---|---|---|
committer | Christian Segundo | 2023-09-16 12:30:18 +0200 |
commit | 447718be411781ae06308299e67dfc2b6bf13695 (patch) | |
tree | 0a1d348e440109958f5d4886ec5347c73cbfcea4 /Jenkinsfile | |
parent | e76c12f98fbce4870422790161876163335fc809 (diff) | |
download | transmission-hacks-447718be411781ae06308299e67dfc2b6bf13695.tar.gz |
sorry
Diffstat (limited to 'Jenkinsfile')
-rw-r--r-- | Jenkinsfile | 69 |
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" + } + } + } + } +} |