It seems like when the job is not an AbstractProject e.g. a WorkflowJob then the job isn't scheduled with parameters https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java#L204
[1] and [2] are some examples on how to schedule a job with parameters where the job implements ParameterizedJobMixIn.ParameterizedJob which any job type that takes parameters should implement (FreeStyle, Workflow Maven etc) There are probably more examples out there. [1] https://github.com/jenkinsci/gerrit-trigger-plugin/blob/master/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/EventListener.java#L231 [2] https://github.com/jenkinsci/dockerhub-notification-plugin/blob/master/src/main/java/org/jenkinsci/plugins/dockerhub/notification/DockerHubWebHook.java#L167 /B On Thu, Nov 12, 2015 at 7:07 AM, Owen Mehegan <[email protected]> wrote: > I tried that, but the values come back null, so I don't think they're > getting set as environment variables per se. > > On Wed, Nov 11, 2015 at 10:04 PM, Mirko Friedenhagen < > [email protected]> wrote: > >> Hello Owen, >> >> as far I know environment variables need to be prefixed with env when >> accessing them from Groovy, so maybe it should be >> "origin/${env.gitlabSourceBranch}" …? >> >> Regards >> Mirko >> -- >> Sent from my mobile >> Am 12.11.2015 00:22 schrieb "Owen B. Mehegan" <[email protected]>: >> >>> 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 >>> <https://groups.google.com/d/msgid/jenkinsci-dev/710c72a2-deee-414e-9fb1-0c86128aff91%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Jenkins Developers" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/jenkinsci-dev/CJEbh85zRx8/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-dev/CAK8jvqxc4xMLTXnYH2xxekJ2c-gnCXEXw6pZX2cx4%3DFcyWvrbw%40mail.gmail.com >> <https://groups.google.com/d/msgid/jenkinsci-dev/CAK8jvqxc4xMLTXnYH2xxekJ2c-gnCXEXw6pZX2cx4%3DFcyWvrbw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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/CAHtcACEJ9aRenR0WNz-u--LMBGEqQbq6MqBQQJ6EZgRjLEjtow%40mail.gmail.com > <https://groups.google.com/d/msgid/jenkinsci-dev/CAHtcACEJ9aRenR0WNz-u--LMBGEqQbq6MqBQQJ6EZgRjLEjtow%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Robert Sandell *Software Engineer* *CloudBees Inc.* -- 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/CALzHZS00VRov2sm-GYjkE0uy6nmo9c9O-CuX4s%3DeWouYUsXRdQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
