admin管理员组

文章数量:1346298

I have a custom script which fetch the secret from vault . ( I cannot use Jenkins credentials to store the secrets )

My code

def executeCommand(def command) {
    return sh(script: command, returnStatus: true, label: "Executing Command")
}
def cred = <call some script > ( Returns {username : '', password : '' } ) 
withEnv(["DOCKER_USER=${cred.username}", "DOCKER_PASS=${cred.password}"]) {
            def command = "printf '%s' \"\$DOCKER_PASS\" | docker login ${DockerRepo}.${tmpRepoUrl} -u \$DOCKER_USER --password-stdin"
            def status = executeCommand(command)
} 

The issue, It is printing the credentials in jenkins logs. [Pipeline] sh (Executing Command) (hide)

  • printf somepassword
  • docker login docker.test -u test --password-stdin WARNING! Your password will be stored unencrypted in /root/.docker/config.json.

How to avoid printing of command msg in Jenkins logs.

本文标签: Masking of secret in Jenkins logsStack Overflow