We have a job which has two build steps:
This works well in Jenkins 1.0, but after migrated to Jenkins 2.0, it retired.
After a google search, it turned out that Jenkins 2.0 has injected a new security advisory, where previous allowed arbitrary parameters are accepted as environment variables, but that is not safe. Now Jenkins forces to use build parameters. But there are always exceptions, for known safe parameters are still allowed in below way:
java -Dhudson.model.ParametersAction.safeParameters=FOO,BAR_BAZ,qux -jar jenkins.war
correspondingly if user is using groovy script to add new ParamtersAction, there is also a corresponding constructor to use.
So in Jenkins 1.0, we have:
import hudson.model.* def build = Thread.currentThread()?.executable def param = new ParametersAction([new StringParameterValue("NEW_PARAM",lang)]) build.addAction(param) return param
Now in Jenkins 2.0:
import hudson.model.* def build = Thread.currentThread()?.executable def param = new ParametersAction([new StringParameterValue("NEW_PARAM",lang)], ["NEW_PARAM"]) build.addAction(param) return param
very small change huh, but it avoids redesign the jobs.
To use this new-added parameter, in later build steps e.g. windows batch command step: