Gitflow and triggering snapshot dependencies for maven multimodule builds

82 views
Skip to first unread message

Richard Hierlmeier

unread,
Jan 12, 2018, 5:55:22 AM1/12/18
to Jenkins Users

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 "" in the section ""Scan Organization Folder Triggers":









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.












Richard Hierlmeier

unread,
Jan 12, 2018, 8:22:37 AM1/12/18
to Jenkins Users

It seems that this is a known problem. I found the following Jira issue: JENKINS-47996
Reply all
Reply to author
Forward
0 new messages