(if you have performed all the above, remove the paragraph and continue describing the issue with template below)
I'm trying to trigger a build on a push tag event for a multibranch pipeline. When I push a tag to Gitlab the tag will show up in Jenkins but won't build. I have to click on Run for it to build. When I click edit it shows the following error:
There was an error loading the pipeline from the Jenkinsfile in this repository. Correct the error by editing the Jenkinsfile using the declarative syntax then commit it back to the repository.
fetch failed: 500 for https://GITLAB/blue/rest/organizations/jenkins/pipelines/my-pipeline/scm/content?path=Jenkinsfile&branch=v0.0.1
I have refspecs as follows +refs/tags/*:refs/remotes/origin/tags/* though I can't see a way to add a branch specifier for a multibranch pipeline.
Jenkinsfile
pipeline {
agent any
options {
// Connection is configured by the Jenkins Gitlab plugin
// Manage Jenkins -> Configure System -> Gitlab
gitLabConnection('my-gitlab')
// Keep only the 2 latest builds.
buildDiscarder(logRotator(numToKeepStr: '2'))
// Prepend all console output generated by the Pipeline run with the time at which the line was emitted
timestamps()
}
triggers {
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All')
}
post {
always {
// clean up our workspace
deleteDir()
}
failure {
updateGitlabCommitStatus name: 'my-pipeline', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'my-pipeline', state: 'success'
}
}
stages {
stage('NPM Install') {
steps {
sh '''
npm config set strict-ssl false
npm set registry https://my-npm/
npm ci
'''
}
}
stage('Checks') {
parallel {
stage('Format') {
steps {
sh 'npm run format:ci'
}
}
stage('Lint') {
steps {
sh 'npm run lint'
}
}
}
}
stage('Dev Build') {
steps {
sh 'npm run build:prod'
}
}
stage('Dev Deploy') {
steps {
sh '*'
}
}
stage('PoC Build'){
when { tag "v*" } // also tried when { buildingTag() }
steps {
sh 'npm run build:poc'
}
}
}
}
No relevant logs
_Please include any relevant log that could serve to better understand the source of your issue_
For Jenkins Gitlab Plugin logs, follow instruction in User Support section.
For Gitlab logs, ask an administrator to provide you the relevant Gitlab logs.
_Describe your problem in a meaningful way_:
Same problem
I ran into the same problem however from what I have read I believe this is by design. See the following links for more details:
https://stackoverflow.com/questions/52404216/trigger-jenkins-build-on-tag-creation-with-multibranch-pipeline
https://issues.jenkins-ci.org/browse/JENKINS-47496
closing as no longer using Jenkins
Most helpful comment
closing as no longer using Jenkins