1

If there is a Jenkins shell script build step, environment variables are set so that, for example, if you echo $WORKSPACE you see the current working directory. I am writing a custom plugin which also can execute shell commands but WORKSPACE is not set when this plugin executes.

I could see that Jenkins sets all those env variables prior to executing the shell commands the Jenkins project specifies so that they would not be already set for a custom plugin. If that is the case, it would seem like there is no way to access those env variables.

But if there is a way to obtain the values of the env variables that would be useful.

2
  • This is a problem which also bothers me. I've built an mwe: github.com/DaGeRe/example-no-environment Neither System.getenv nor run.getEnvironment(listener) are able to get defined environment variables. Unfortunately, I did not find any solution so far, so I would be glad if you could share a solution if you found one. Commented Mar 17, 2021 at 12:51
  • This seems to be a duplicate of stackoverflow.com/questions/14214249/… Commented Mar 17, 2021 at 19:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.