Files sourced on pipeline shell step

23 views
Skip to first unread message

Kamil Dzierżanowski

unread,
Jan 9, 2019, 4:19:25 AM1/9/19
to Jenkins Users
Hello,

I'm trying to determine, which (if any) files are sourced by the shell, in which commands specified in "sh" pipeline step are executed. I need to make sure the NVM (Node Version Manager) is sourced everytime this step is used.
I tried numerous dot-files for the user the Jenkins agent is using, as well as the /etc/profile, but none works. I'll be grateful for any hints or for pointing me to an existing answer (I failed to find any).

Kamil

Neil T

unread,
Jan 10, 2019, 9:18:32 AM1/10/19
to Jenkins Users

Martin Baillie

unread,
Jun 15, 2020, 3:18:58 PM6/15/20
to Jenkins Users
 I'm experiencing a similar issue, did you find a solution?


On Wednesday, 9 January 2019 09:19:25 UTC, Kamil Dzierżanowski wrote:

Kamil Dzierżanowski

unread,
Jun 16, 2020, 3:47:10 AM6/16/20
to Jenkins Users
It looks like the "sh" step uses the same shell session that the Jenkins agent does when connecting a node to master. Therefore, any default shell configuration is determined in node settings, and changing it, or any of the dot files, requires reconnecting the node to reload them.

I would say it is a best practice to use a Jenkins Shared Library and define a custom step, which will use the "sh" step to run a specified command in a new "bash" login session. That way you can ensure the proper dot files, NVM etc. are always sourced fresh.
Reply all
Reply to author
Forward
0 new messages