I'm trying to take the jenkins gradle plugin and make it compatible with the new workflow job type. I've gotten it to the point where I can use something like this and it will run gradle pretty successfully:
step([$class: 'Gradle',
switches: "-PenableInstallerDistribution=true",
tasks: 'build install',
gradleName: '(Default)',
useWrapper: true,
makeExecutable: true,
fromRootBuildScriptDir: true,
useWorkspaceAsHome: true])
However, I had to make some sacrifices. I had to simply delete these lines:
Set<String> sensitiveVars = build.getSensitiveBuildVariables();
args.addKeyValuePairs("-D", fixParameters(build.getBuildVariables()), sensitiveVars);
I can't find any way to access the "sensitive variables" from the Run
object that is supplied in place of the old AbstractBuild
and popping passwords into the console output seems like a bad idea. (I believe that's what the code is trying to avoid doing; I didn't write the original.)
There is currently no
Run.getSensitiveBuildVariables()
, though it is possible one is needed. Anyway this method is merely communicating to other plugins which variables might be considered secrets for various purposes; it is not responsible for making passwords included in the command line fromProcStarter
be shown as****
in the build log, which would be done usingArgumentListBuilder.addMasked
.The quick answer is that, pending newer APIs, you should just skip this block if not given an
AbstractBuild
.