Multibranch Pipeline trigger

113 views
Skip to first unread message

Thomas Keller

unread,
Nov 8, 2016, 3:47:23 AM11/8/16
to Jenkins Users
Hey all!

I have multiple library projects that I build as multibranch pipelines. Naturally these library projects have dependencies and usually fetch these dependencies as a SNAPSHOT artifact from a previous build of the other library.

For the case where a such a dependency gets a change, I want to trigger a new build for all dependent library builds. These are my Jenkinsfile's for the two repos:


* in foo.git/Jenkinsfile


#!/usr/bin/env groovy

node
{
    stage
('Test') {
        checkout scm
        sh
"( sleep 5 && echo foo )"
   
}
}


* in bar.git/Jenkinsfile:

#!/usr/bin/env groovy

properties
([
    pipelineTriggers
([
        upstream
(
            threshold
: hudson.model.Result.SUCCESS,
            upstreamProjects
: 'repos/foo/master'
       
)
   
])
])

node
{
    stage
('Test') {
        checkout scm
        sh
"( sleep 5 && echo bar )"
   
}
}


Both Jenkins projects are saved underneath the directory "repos". Now I tried several versions how to reference "upstreamProjects", with relative paths "../../foo/master", "../foo/master" or simply "foo/master", or with the absolute path like above, but all without success: the "bar.git" project is just never triggered.


What am I doing wrong? Is this even a supported use case and if not, what are my alternatives given the above setup?


Thanks in advance,

Thomas.

Thomas Keller

unread,
Nov 10, 2016, 7:27:30 AM11/10/16
to Jenkins Users
*bump*

Thomas Keller

unread,
Nov 14, 2016, 5:17:52 AM11/14/16
to Jenkins Users
Has anybody an idea?

Thomas Keller

unread,
Nov 15, 2016, 4:40:10 AM11/15/16
to Jenkins Users
Ok, I figured it out myself. Several issues on my side:

1) In order to get the upstream trigger set up, the dependent project needs to be run at least once, otherwise Jenkins obviously does not know anything about the trigger in first place.
2) Absolute project references of course need to start with a slash, i.e. /repos/barrepo/master
3) If relative project references are used, you need to remember that - by default - the trigger code resolves these references relative to the _parent_ project of the build. So if you have foorepo/master and barrepo/master, then you need to use "../barrepo/master", and not "../../barrepo/master" or anything alike.
Reply all
Reply to author
Forward
0 new messages