Need a replacement for setUpEnvironment that can be used in Pipeline jobs

65 views
Skip to first unread message

Owen B. Mehegan

unread,
Apr 27, 2016, 8:19:07 PM4/27/16
to Jenkins Developers
I help maintain the Jenkins GitLab plugin, and a recent major refactor (by someone else) broke our rudimentary Pipeline job type support. We have clawed our way back to partial support now, where I can get the plugin to trigger a Pipeline job, but we're stuck on the fact that none of the necessary parameters for the build are set. Looking at our code, I think the problem is that we use setUpEnvironment() for that, which I understand doesn't make sense in Pipeline. I'm not sure where we should go from here. There is a more complete explanation of my findings, with links to the relevant code, here: https://github.com/jenkinsci/gitlab-plugin/issues/271#issuecomment-215270683

Gavin Mogan

unread,
Apr 27, 2016, 10:48:37 PM4/27/16
to Jenkins Developers
I did something similar for the saucelabs plugin


This produces sauce {} block (due to takesImplicitBlockArgument) which makes a new context with new environment variables.

Antonio Muñiz

unread,
Apr 28, 2016, 4:54:14 AM4/28/16
to jenkin...@googlegroups.com
Perhaps you can switch `GitLabEnvironmentRunListener` to extend
`EnvironmentContributor` instead of `RunListener`, so any injected
environment variable will be available in a Pipeline as a groovy
variable.
> --
> 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 jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/4ad63739-e44a-41d9-a58f-bef8da8d8ef8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Jesse Glick

unread,
Apr 28, 2016, 9:40:59 AM4/28/16
to Jenkins Dev
On Thu, Apr 28, 2016 at 4:53 AM, Antonio Muñiz <amu...@cloudbees.com> wrote:
> any injected
> environment variable will be available in a Pipeline as a groovy
> variable.

Well, no, they will be available using `env.PROP` syntax, or of course
as environment variables for external processes you launch.
JENKINS-29952 proposes a unification.
Reply all
Reply to author
Forward
0 new messages