jenkinsci / jenkinsci/credentials-plugin

[JENKINS-51763] Hide credentials given to the dockerfile

Open
#808 1 comment 0 reactions 0 assignees View on GitHub
component:credentials-plugin imported-jira-issue priority:critical resolution:unresolved
Dominant language
Java
Stars
134
Forks
258
Avg merge
48m
Merged PRs (30d)
1

Description

When using jenkins with docker plugin, If I try to launch a dockerfile from pipeline with credentials as AdditionalArguments:

def BUILDARGS

node {
withCredentials([usernamePassword(credentialsId: 'credId', passwordVariable: 'nexusPassword', usernameVariable: 'nexusUser')]) {
BUILDARGS = "--build-arg nexusUser=${nexusUser} --build-arg nexusPassword=${nexusPassword}"
}
}
agent {
dockerfile {
dir "${projectRootLocation}"
additionalBuildArgs "$BUILDARGS"
label 'Docker'
}
}

Jenkins display the content of the command line :

[Pipeline] sh

[tform_xxxxxx_master-JY4H63NYHB6VJMKUFIMC2R2JWRWXIDSJ63WJCYILIZ35Y5AVGIUA] Running shell script

docker build -t 5c5a6f87c431d14fd800e3cad7bb1d9af131caa4 --build-arg nexusUser=username --build-arg nexusPassword=password -f ./Dockerfile .
Sending build context to Docker daemon 123.1MB


So it possible to hide the password and the user on the command line ?

Thanks

---
Originally reported by 20100, imported from: Hide credentials given to the dockerfile


  • status: Open
  • priority: Critical
  • component(s): credentials-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 5
  • imported: 2025-12-08

Raw content of original issue

When using jenkins with docker plugin, If I try to launch a dockerfile from pipeline with credentials as AdditionalArguments:



def BUILDARGS

node {
withCredentials([usernamePassword(credentialsId: 'credId', passwordVariable: 'nexusPassword', usernameVariable: 'nexusUser')]) {
BUILDARGS = "--build-arg nexusUser=${nexusUser} --build-arg nexusPassword=${nexusPassword}"
}
}
agent {
dockerfile {
dir "${projectRootLocation}"
additionalBuildArgs "$BUILDARGS"
label 'Docker'
}
}


Jenkins display the content of the command line :



[Pipeline] sh

[tform_xxxxxx_master-JY4H63NYHB6VJMKUFIMC2R2JWRWXIDSJ63WJCYILIZ35Y5AVGIUA] Running shell script

docker build -t 5c5a6f87c431d14fd800e3cad7bb1d9af131caa4 --build-arg nexusUser=username --build-arg nexusPassword=password -f ./Dockerfile .
Sending build context to Docker daemon 123.1MB



So it possible to hide the password and the user on the command line ?

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.