How do we access the sensitive variables in a jenkins plugin that is workflow compatible?

283 views Asked by At

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.)

1

There are 1 answers

0
Jesse Glick On BEST ANSWER

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 from ProcStarter be shown as **** in the build log, which would be done using ArgumentListBuilder.addMasked.

The quick answer is that, pending newer APIs, you should just skip this block if not given an AbstractBuild.