Earlier this year I bribed an intern and another coworker to implement
Workflow support in the GitLab plugin
(https://github.com/jenkinsci/gitlab-plugin for reference). They made an
initial pass at it, with support from jglick. Now I've realized that the
support is incomplete. We've since taken over maintainership of the plugin,
but we're still totally inexperienced with Jenkins plugin code. I have two
issues that we need help with.
First, I can't figure out how to access the branch parameters that the
plugin is setting. If you look at the 'Using it with a job' section of the
readme, it has you configure Git to expect variables like
gitlabSourceBranch and gitlabTargetBranch to be set when a build is
triggered by Gitlab. This works fine in freestyle builds. In a Workflow
build, I used the snippet generator and it gave me this output (corrected
with double quotes around strings containing variables):
checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[
name: "origin/${gitlabSourceBranch}"]], doGenerateSubmoduleConfigurations:
false, extensions: [[$class: 'PreBuildMerge', options: [fastForwardMode:
'FF', mergeRemote: 'origin', mergeTarget: "${gitlabTargetBranch}"]]],
submoduleCfg: [], userRemoteConfigs: [[name: 'origin', url:
'[email protected]:test/testrepo.git']]]
But when the job is triggered, those variables are not set - I get a
groovy.lang.MissingPropertyException
for them. I'm pretty sure that the relevant part of the plugin code is
here:
https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java#L235
Beyond that, I'm clueless as to what might need to change.
Second, it seems that if the most recent build of the project failed to
check out the repo, the plugin fails to trigger any further builds. It logs
the error, 'Could not find GitSCM for project,' and that's generated here:
https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java#L802
I guess this is related to the fact that the plugin ALSO can't trigger a
brand new job until you run it manually one time. Jesse mentioned that this
would be a problem - running it causes it to store some gitSCM state which
the plugin is then able to find. I would love to find a more elegant way to
handle this case. I wonder if there's a way to create an additional field
in the job config, outside the Workflow script, where we could specify the
repo URL and have the plugin key off of that.
Thanks in advance for any guidance anyone can offer :)
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" 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-dev/710c72a2-deee-414e-9fb1-0c86128aff91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.