I try to setup Jenkins Job for a Maven multimodule build. The development
team likes to follow a gitflow workflow.
- We use a Bitbucket Team Project
- We have a develop branch that builds and deploys the SNAPSHOT versions
to nexus.
- Each feature is developed in a separate feature branch. The feature
branches only install, but do not deploy the artifacts.
- It is normal that the poms of the feature branch has the same version
number as the branch of the develop branch.
Is setup the following pipeline for this job:
def branchType = getBranchType "${env.BRANCH_NAME}"
def buildGoals = "clean install"
if (branchType == "dev") {
buildGloals = "clean deploy"
}
pipeline {
agent {
node { label 'maven' }
}
triggers {
upstream(upstreamProjects: 'Nightly Build Trigger', threshold:
hudson.model.Result.SUCCESS)
snapshotDependencies()
}
stages {
stage('Build and Deploy') {
steps {
withMaven(
mavenLocalRepo: '.repository'
) {
sh "mvn ${buildGoals}"
}
}
}
}
}
In the config of the Bitbucket Team Project I selected the option "Build
whenever a SNAPSHOT dependency is built" in the section ""Scan Organization
Folder Triggers":
<https://lh3.googleusercontent.com/-CQE9AmGqVvQ/WliPUHju2tI/AAAAAAAAAJE/IFW4wFSY8Jcb1tU97hJf3BPj9EpjUm2AACEwYBhgL/s1600/2018-01-12%2B11_34_25-9999-998%2BGIT%2BFlow%2BTest%2BConfig%2B%255BJenkins%255D.png>
My multi module build has two artifacts: A 1.0.0-SNAPSHOT and B
1.0.0-SNAPSHOT. B depends on A.
The version numbers in the feature branch and in the develop branch are
equal.
I run now the in the following problem:
Build of develop branch builds A 1.0.0-SNAPSHOT -> Build of feature branch
is triggered, because module B has module A 1.0.0-SNAPSHOT as dependency
Build of feature branch builds A 1.0.0-SNAPSHOT -> Build of develop branch
is triggered, because moduel B has module A 1.0.0-SNAPSHOT as dependnecy.
We have an infinite loop.
How can we avoid this situation?
I tried the following:
triggers {
upstream(upstreamProjects: 'Nightly Build Trigger', threshold: hudson.
model.Result.SUCCESS)
if (branchType == "dev" ) {
snapshotDependencies()
}
}
But I get a syntax error.
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/2595ab4c-bc87-427c-bc1d-51e8630f7716%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.