Triggering pipeline builds when a commit is pushed to a branch or when a tag that matches a regex is pushed.

18 views
Skip to first unread message

Francis Chuang

unread,
Jul 14, 2019, 7:38:04 PM7/14/19
to jenkins...@googlegroups.com
Hey all,

I have a question with configuring Jenkins that I have been struggling
with for a while. We are using Jenkins 2.150.1.

My jenkinsfile looks like this:
pipeline {
agent {
node {
label 'some-node'
}
}

environment {
COMPOSE_PROJECT_NAME = "${env.JOB_NAME}-${env.BUILD_ID}"
}

options {
timeout(time: 40, unit: 'MINUTES')
}

stages {
stage('Build Site') {
when {
branch 'test-site'
}
steps {
...
}
}

stage('Build Javadoc') {
when {
buildingTag()
}
steps {
...
}
}

stage('Deploy Site') {
when {
branch 'test-site'
}
steps {
...
}

stage('Deploy Javadoc') {
when {
buildingTag()
}
steps {
...
}
}
}
post {
always {
sh 'docker system prune --force --all'
}
}
}

I want to run a pipeline when a commit is pushed to a branch. I am able
to do this by setting "Branches to build" to `refs/heads/test-site`.

However, I also need to build a pipeline when a tag that matches a regex
is pushed. I tried adding a refspec following
https://mohamicorp.atlassian.net/wiki/spaces/DOC/pages/136740885/Triggering+Jenkins+Based+on+New+Tags
, however it doesn't trigger the build.

Does anyone have any tips for how to get this to work?

Francis

Tomas Bjerre

unread,
Aug 10, 2019, 7:18:40 AM8/10/19
to Jenkins Users
Reply all
Reply to author
Forward
0 new messages