2
votes

I am passing a secret value using -D in maven Goals and options on jenkins. I don't want to output this secret value to console for security reasons. e.g. maven command in Goals and option on Jenkins look like this:

clean install -DnewSecret=newGeneratedSecret

When the job is run this is printed in console output:

Executing Maven:  -B -f /workspace/pom.xml clean install -DnewSecret=newGeneratedSecret

Any idea how to stop printing this? I tried these but didn't work:

clean install -q -DnewSecret=newGeneratedSecret
clean install -DnewSecret=newGeneratedSecret > null

Update: please note the secret value is a generated value which is then set as env variable using EnvInject jenkins plugin.

1

1 Answers

1
votes

You could use the Mask Passwords Plugin to define a masked variable for newSecret (e.g., named "SECRET") under Build Environment > Mask Passwords and then use it in your Maven options as an environment variable:

clean install -DnewSecret=${SECRET}

The console would show this:

Executing Maven:  -B -f /workspace/pom.xml clean install -DnewSecret=**********