New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support env variable configuration in global listener [JENKINS-62753] #105
support env variable configuration in global listener [JENKINS-62753] #105
Conversation
@asimell You are an assignee on Jira so perhaps you want to take a look. |
@agaudreault-jive Thank you so much for the PR! I started working on this a few weeks ago, but got distracted once again and almost forgot about it. Without testing the PR looks good already, I really appreciate the updated documentation even for parts that aren't really part of this feature. I'll test this out and merge if everything works as expeced. |
Clarify that only tags are for all metrics
@asimell tested on my side and everything is working as expected. I added instructions in the PR description that might be useful. I hope this can be part of 2.5 release soon 😄 🚀 |
@agaudreault-jive Am I assuming correctly here that I can't simply set the environment variables in "traditional" pipeline manner
and in order to use this feature I should create a separate library just to extend the environment variables into the |
@asimell Correct. From what I tried, the "traditional" way will simply set the variable for the duration of the pipeline, but they won't be available on the Run object. It is available on the AbstractRun, but this is not used with workflow pipelines. I don't know if there is another way to set the environment variables in a way that they are persisted outside the pipeline, but I do not think this should be part of this plugin. Perhaps there’s a way with the EnvInject plugin, but this one is up for adoption and pipeline syntax is not much documented. |
@asimell Is there another blocker for this PR ? |
@agaudreault-jive No other blockers, just my time allocation 😅. My civil life got slightly "in the way" of having any energy to look at this. Sorry for the delay, I'll try to check this as soon as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After getting all the permissions set to Jenkins, this works like a charm.
Fix: https://issues.jenkins-ci.org/browse/JENKINS-62753
Example Pipeline
This is the pipeline I used to test
Note that
publishEnv
is defined in a shared libraryFile:
vars/publishEnv.groovy
File:
scr/com/example/action/PublishEnvVarAction.groovy
The class
PublishEnvVarAction
will need to be whitelisted for serialization with-Dhudson.remoting.ClassFilter=com.example.action.PublishEnvVarAction
or you will get an error likeRefusing to marshal com.example.action.PublishEnvVarAction for security reasons; see https://jenkins.io/redirect/class-filter/
Result
I can see the 2 tags
multiline=works
andmy_tag=foo
expanded correctly with multiline working.The custom field
my_field="1"
is present.Both
prefix
andproject_name
values are the proper one.TODOs