I'm setting up a CI scheme for a few projects, on Jenkins, using the multibranch plugin. Everything is working pretty nicely, but the obsessive in me always wants a bit more.
Current situation:
The multibranch thingy is working: picks up and builds new branches and PRs. It does so by polling: Every N minutes it polls Github for new branches and branch updates.
I want:
I would very much like to build new pushes on Github Webhook push events and avoid polling. When not dealing with multibranch, it was as simple as checking the GitHub hook trigger for GITScm polling
box.
In this context, I would have to add a new trigger to the Jenkinsfile. I assume something like:
triggers {
githubWebhook()
}
Currently, my Jenkinsfile is something like this:
pipeline {
agent {
docker {
image '${REDACTED}/builder:sbt-0.13-jdk-oracle-8'
args '-v sbt-cache:/root/.sbt/ -v ivy-cache:/root/.ivy2/'
customWorkspace '/src/'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps()
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('Testing') {
steps {
sh "sbt clean coverage test coverageReport coverageAggregate sonar"
}
}
stage('Push snapshot'){
when {
not {
branch 'master'
}
}
steps {
echo "[DRYRUN] sbt publishSnapshot"
}
}
stage('Push release') {
when {
branch 'master'
}
steps {
echo "[DRYRUN] sbt publish"
}
}
}
post {
changed {
echo "[DRYRUN] changed build"
}
}
}
Has anyone dealt with something like this? Any other approach?