From c82e353e08e2d6c1a453c8266fdb6356b8f2758d Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 26 Dec 2019 16:28:56 +0100 Subject: Jenkins: auto publish container to DockerHub --- Jenkinsfile | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'Jenkinsfile') diff --git a/Jenkinsfile b/Jenkinsfile index 2abfa282..d01a31be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,16 +62,35 @@ def setDescription() { item.save() } -/* Only keep the 10 most recent builds. */ +// Only keep the 10 most recent builds def projectProperties = [ - [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '1']], + [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '10']], ] properties(projectProperties) setDescription() +// Due to long build times on DockerHub we rather build the container by ourself +// and publish it later on. +node('Docker') { + stage('Build Container') { + script { + git branch: getGitBranchName(), + url: getGitRepoURL() + + // create container name on demand + env.DOCKER_IMAGE = "vyos/vyos-build:" + getGitBranchName() + sh "docker build -t ${env.DOCKER_IMAGE} docker" + withDockerRegistry([credentialsId: "DockerHub"]) { + sh "docker push ${env.DOCKER_IMAGE}" + } + } + } +} + pipeline { options { + skipDefaultCheckout() disableConcurrentBuilds() timeout(time: 90, unit: 'MINUTES') parallelsAlwaysFailFast() @@ -87,21 +106,17 @@ pipeline { } } stages { - stage('Configure') { + stage('Build ISO') { steps { script { def commitId = sh(returnStdout: true, script: 'git rev-parse --short=11 HEAD').trim() currentBuild.description = sprintf('Git SHA1: %s', commitId[-11..-1]) sh './configure --build-by autobuild@vyos.net --debian-mirror http://ftp.us.debian.org/debian/' + sh 'sudo make iso' } } } - stage('Build') { - steps { - sh 'sudo make iso' - } - } } post { cleanup { -- cgit v1.2.3