Skip to content

Commit

Permalink
Jenkinsfile: Prepare for introducing git tag release builds
Browse files Browse the repository at this point in the history
schnatterer committed Apr 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 22b37f7 commit 8465bab
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ node('high-cpu') {
stage('Checkout') {
checkout scm
git.clean('')
// Otherwise git.isTag() will not be reliable. Jenkins seems to do a sparse checkout only
sh "git fetch --tags"
}

stage('Build cli') {
@@ -128,23 +130,25 @@ node('high-cpu') {
if (isBuildSuccessful()) {
docker.withRegistry("https://${dockerRegistryBaseUrl}", 'cesmarvin-ghcr') {
// Push prod image last, because last pushed image is listed on top in GitHub
if (git.isTag()) {

if (git.isTag() && env.BRANCH_NAME == 'main') {
// Build tags only on main to avoid human errors

images[1].push()
images[1].push(git.tag + '-dev')
images[1].push('dev')
images[1].push('latest-dev')
images[0].push()
images[0].push('latest')
images[0].push(git.tag)

currentBuild.description = createImageName(git.tag)
currentBuild.description += "\n${imageNames[0]}"

} else if (env.BRANCH_NAME == 'main') {
images[1].push()
images[1].push('dev')
images[1].push('latest-dev')
images[0].push()
images[0].push('latest')
currentBuild.description = createImageName('latest')
currentBuild.description += "\n${imageNames[0]}"
currentBuild.description += "${imageNames[0]}"
} else if (env.BRANCH_NAME == 'test') {
images[1].push()
images[1].push('test-dev')

0 comments on commit 8465bab

Please sign in to comment.