diff options
author | Christian Segundo | 2024-04-07 10:45:05 +0200 |
---|---|---|
committer | Christian Segundo | 2024-04-07 18:19:48 +0200 |
commit | 8206fecdb86f05d353ef25c9596cebca5c1d28fb (patch) | |
tree | 169f50213c94e8a558bf1c235871c764045f4338 /Jenkinsfile | |
parent | 3891426ce8deba513c5bcf1594987bdcfc837304 (diff) | |
download | jenkins-agent-docker-cli-8206fecdb86f05d353ef25c9596cebca5c1d28fb.tar.gz |
install buildx
Diffstat (limited to 'Jenkinsfile')
-rw-r--r-- | Jenkinsfile | 89 |
1 files changed, 20 insertions, 69 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index 4426a26..ce6bb7f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,74 +1,25 @@ -String cron_string = BRANCH_NAME == "master" ? "@daily" : "" +String cron_string = BRANCH_NAME == "master" ? "@weekly" : "" + pipeline { - agent { - docker { - image 'quay.io/buildah/stable' - args '--privileged=true' - } - } - options { parallelsAlwaysFailFast() } - triggers { cron(cron_string) } - environment { - PROJECT = 'jenkins-agent-docker-cli' - IMAGE_NAME = "docker.io/chn2guevara/$PROJECT" - } - stages { - stage('Prepare') { - steps { - sh 'dnf install git -y' - script { - env.TAG_NAME = sh( - returnStdout: true, - script: 'git name-rev --name-only --tags HEAD | sed \'s/^undefined$//\'').trim() - } - } - } - stage('Manifest') { - steps { sh "buildah manifest create $PROJECT" } - } - stage('Build') { - parallel { - stage('arm64/v8') { - steps { - sh""" - buildah build --pull --platform linux/arm64/v8 --network host \ - --tag $IMAGE_NAME:latest --manifest $PROJECT . - """ - } + agent any + triggers { cron(cron_string) } + options { ansiColor('xterm') } + stages { + stage('Check') { + agent { + docker { + image 'ghcr.io/super-linter/super-linter:latest' + args '--entrypoint ""' + } + } + steps { sh 'bash .scripts.d/10-check.sh' } } - stage('amd64') { - steps { - sh""" - buildah build --pull --platform linux/amd64 --network host \ - --tag $IMAGE_NAME:latest --manifest $PROJECT . - """ - } + stage('Build') { steps { sh 'bash .scripts.d/20-build.sh' } } + stage('Test') { steps { sh 'bash .scripts.d/30-test.sh' } } + stage('Publish') { + environment { DOCKERHUB_TOKEN = credentials('DOCKERHUB_TOKEN') } + steps { sh 'bash .scripts.d/40-publish.sh' } } - } - } - stage('docker.io login') { - when { branch 'master' } - steps { - withCredentials([string( - credentialsId: 'dockerhub-personal', - variable: 'CREDENTIALS') - ]) { - sh '''#!/bin/bash - IFS=" " read -r username password <<<"$CREDENTIALS" - buildah login \ - --username "$username" \ - --password-stdin <<< "$password" docker.io - ''' - } - } - } - stage('Push latest') { - when { branch 'master' } - steps { sh "buildah manifest push --all $PROJECT docker://$IMAGE_NAME:latest" } - } - stage('Push tag') { - when { allOf { branch 'master'; expression { return env.TAG_NAME == '' ? false : true } } } - steps { sh "buildah manifest push --all $PROJECT docker://$IMAGE_NAME:$TAG_NAME" } } - } + post { always { junit 'build/reports/*.xml' } } } |