Using git hook with Workflow Plugin with 'computed' repository url?

65 views
Skip to first unread message

Kenneth Baltrinic

unread,
Feb 3, 2015, 12:04:01 PM2/3/15
to jenkins...@googlegroups.com
We are using a function in our cps global library to perform our git fetch.  This function looks something like:

def getFromStash(stashProject, stashRepo) {
    checkout changelog
: true, poll: true, scm: [
        $class
: 'GitSCM',
        branches
: [[name: '*/master']],
        doGenerateSubmoduleConfigurations
: false,
        submoduleCfg
: [],
        userRemoteConfigs
: [[
            credentialsId
: 'e01b632a-4bb4-446b-9d93-793565f2293f',
            url
: "ssh://git@stash:7999/${stashProject}/${stashRepo}.git"
       
]]
   
]
}


It appears that using such an approach (which interestingly is the example given for using a cps global library) to pulling from SCM breaks the git-hook because the workflow plug-in is unable to determine, without running the workflow, the url that the job is going to pull from.  (Specifically the hook when invoked reports no matching jobs found) 

Is there any way around this?  It seems like this would also break basic SCM polling as well would it not?  Given that this is the example for using a global library, I am hoping there is a right way to do this, because not being able to poll nor be triggered is something of a problem.

Kenneth Baltrinic

unread,
Feb 3, 2015, 1:47:14 PM2/3/15
to jenkins...@googlegroups.com
I dug into the source code and figured this out.  Jenkins does not attempt to parse the groovy code to determine the url, rather it captures the actual URLs that were fetched the last time the job ran.  Thus the problem I was having was not due to Jenkins not being able to figure out the url per se, it was that I was testing by trying to trigger a new test job that had never run.  

So for scm hooks and scm polling to work with workflow jobs, the job must first run once, and not fail prior to attempting to fetch from smc.  My only remaining question is, is this documented anywhere?

Baptiste Mathus

unread,
Feb 4, 2015, 2:43:56 AM2/4/15
to jenkins...@googlegroups.com

Cool you dug on that one. Though I'm not sure for your question, I would advise you to simply go ahead and file a pull request on some .md of the workflow-plugin codebase. This way this information will either be put by committers elsewhere at the right place or be just merged. In both case you won't have done all that for nought ;).

Cheers

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ef45cdea-c544-4f0a-96aa-4b233c88a459%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Glick

unread,
Feb 25, 2015, 6:05:16 PM2/25/15
to jenkins...@googlegroups.com
On Tuesday, February 3, 2015 at 1:47:14 PM UTC-5, Kenneth Baltrinic wrote:
My only remaining question is, is this documented anywhere?

Yes; but apparently not well enough. :-/ 
Reply all
Reply to author
Forward
0 new messages