[JIRA] (JENKINS-61735) Add STAGE_NAME and NODE_NAME to environment parameters

5 views
Skip to first unread message

thierry.gatineau@nokia.com (JIRA)

unread,
Mar 29, 2020, 4:54:03 PM3/29/20
to jenkinsc...@googlegroups.com
Thierry GATINEAU created an issue
 
Jenkins / Improvement JENKINS-61735
Add STAGE_NAME and NODE_NAME to environment parameters
Issue Type: Improvement Improvement
Assignee: Jakub Bochenski
Attachments: jenkinsfile
Components: logstash-plugin
Created: 2020-03-29 20:53
Environment: logstash-2.3.2
Labels: plugin jenkins
Priority: Minor Minor
Reporter: Thierry GATINEAU

I use logstash-plugin to send console logs to a server Graylog.

The jenkins job is a declarative pipeline with several stages that runs in parallel on different kind of agent (See attached example).

I expected to find in Graylog, for each line of the console logs, the environment variables of the stage that is running with at least the environment variables such as STAGE_NAME and NODE_NAME that would help to extract logs for a dedicated stage.

But I found in Graylog environment variables of the parent build and therefore I don't find the STAGE_NAME and the NODE_NAME.

As the stage might run in parallel, the logs of each stages are mixed and it is impossible to setup some graylog filters to watch a dedicated stage.

I would like to have the NODE_NAme to discover some correlation between errors that might be seen in the log and the agent that was running the stage.

I dig inside the code and found in BuildData.java that it was the build.getEnvironment(listener) that recovers the environment variables of the parent build.

If I want to make some evolution of the plugin, what advise would you give to recover the environment parameters of the stage instead of the parent build in BuildData.java? 
I did not found any solution via the variable "build".

Thanks by advance for any help.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Mar 30, 2020, 10:48:02 AM3/30/20
to jenkinsc...@googlegroups.com
Jakub Bochenski commented on Improvement JENKINS-61735
 
Re: Add STAGE_NAME and NODE_NAME to environment parameters

I'm not sure what do you mean by "parent build" in the context of Jenkins pipeline

thierry.gatineau@nokia.com (JIRA)

unread,
Mar 31, 2020, 7:45:02 AM3/31/20
to jenkinsc...@googlegroups.com

I mean that the recovering of build.getEnvironment() provides only a subset of environment variables that does not includes the STAGE_NAME and the NODE_NAME parameters.

I've figured out how to recover the whole set of environment variables thanks to: 

hudson.EnvVars envVars = context.get(hudson.EnvVars.class);

I've prepared and tested some code that can be found in https://github.com/jenkinsci/logstash-plugin/pull/92

 

Reply all
Reply to author
Forward
0 new messages