How can I set an environment variable which is only known in the jenkins workspace using a bash script (no plugins)
Asked
Active
Viewed 150 times
1 Answers
1
You can define a variable without using other Plugins by using Groovy . Within your Groovy System Script, you can add following snippet for creating Env parameters:
import hudson.model.*
def build = Thread.currentThread().executable
def myVar = new ParametersAction([
new StringParameterValue("The_TING", "goes_skraaa!")
])
build.addAction(myVar)
Then you can access this variable in the next build step which (for example) can be a windows batch command:
@echo off
Setlocal EnableDelayedExpansion
echo The_TING=!The_TING!
This echo will show you "goes_skraaa!".

Manmohan_singh
- 1,776
- 3
- 20
- 29
-
Any idea? groovy.lang.MissingPropertyException: No such property: executable for class: java.lang.Thread – DenCowboy Nov 27 '17 at 11:09
-
I have been using Jenkins 1.86 . This issue must be due to version difference. This issue is resolved [here](https://stackoverflow.com/questions/38119560/jenkins-groovy-script-errorQ) – Manmohan_singh Nov 27 '17 at 11:15