Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (11.4k points)
recategorized by

I would like to be able to do something like:

AOEU=$(echo aoeu)


and have Jenkins set AOEU=aoeu.

The Environment Variables section in Jenkins doesn't do that. Instead, it sets AOEU='$(echo aoeu)'.

How can I get Jenkins to evaluate a shell command and assign the output to an environment variable?

Eventually, I want to be able to assign the executor of a job to an environment variable that can be passed into or used by other scripts.

1 Answer

+1 vote
by (32.3k points)

You can try using EnvInject plugin in the following way:

  1. Create an "Execute shell" build step that runs

         echo AOEU=$(echo aoeu) > propsfile

   2. Create an Inject environment variables build step and set "Properties File Path" to propsfile.

Note: Usually, this plugin is not compatible with the Pipeline plugin.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...