I've a group of multibranch pipeline jobs generated with the following piece groovy script:
[
'repo1',
'repo2',
].each { service ->
multibranchPipelineJob(service) {
displayName(service)
branchSources {
git {
remote("[email protected]:whatever/${service}.git")
credentialsId('gitlab-ssh-key')
}
}
orphanedItemStrategy {
discardOldItems {
daysToKeep(0)
numToKeep(30)
}
}
triggers {
periodic(5)
}
}
}
and in each repo a Jenkinsfile
that looks as follows:
#!/usr/bin/env groovy
properties([
gitLabConnection('[email protected]'),
pipelineTriggers([
[
$class : 'GitLabPushTrigger',
triggerOnPush : true,
triggerOnMergeRequest: true,
]
]),
disableConcurrentBuilds(),
overrideIndexTriggers(false)
])
node {
def sbtHome = tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder\$SbtInstallation'
stage('Checkout') {
checkout scm
}
stage('Build') {
sh "'${sbtHome}/bin/sbt' clean compile"
}
stage('Test') {
sh "'${sbtHome}/bin/sbt' test"
}
if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master') {
stage('Publish') {
sh "'${sbtHome}/bin/sbt' publish"
}
}
}
It all works correctly. The seeder project generates all the folders from the first script and all the branches for given repo are built correctly.
Unfortunately I've problems with triggering a build for any branch after commit + push has been made to gitlab.
I've jenkins configured correctly - I mean the gitlab plugin, there is a connection and it all works well.
I've also added a webhook on the gitlab side and it also runs correctly. After a test push is sent I receive 200 OK
from jenkins and I do see in logs that scanning the branches has started and detected the changes correctly. Unfortunately the build for the changed branch does not start. Here's an extract from branch scan log:
Checking branch ci
‘Jenkinsfile’ found
Met criteria
Changes detected: ci (a7b9ae2f930b0b10d52bb42f1ecf96a68bba4a30 → 39a4c1a65051d5e90079feec14ad22455a77c58e)
Did not schedule build for branch: ci
I'm 100% sure that this not a problem with communication between my jenkins instance and gitlab account. I see the webhook being triggered after push to gitlab, I see the request being send and branch scan being run. Changes are also detected but why on earth the job isn't started? I've also read the docs thoroughly and have it all configured correctly.
Jenkins version: 2.150.3
Gitlab version: 11.8.1-ee
EDIT
It seems that after upgrading jenkins to v.2.164.1 it all started working correctly.