Do not print Maven Goals and options command to Console Output in Jenkins

时间:2016-04-15 15:01:30

标签: java maven jenkins console

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 个答案:

答案 0 :(得分:1)

您可以使用Mask Passwords Plugin构建环境>下为newSecret定义屏蔽变量(例如,命名为“SECRET”)。掩码密码,然后在Maven选项中将其用作环境变量:

clean install -DnewSecret=${SECRET}

控制台会显示:

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