In my Jenkins job I need to login to Artifactory
I've created a global credentials called "Docker_artifactory_creds"
In job I created bindings for that creds
to use them in an "Execute shell" step as
docker login artifacts.some_custom.com -u ${ARTIFACTORY_USER} -p ${ARTIFACTORY_PASSWD}
but that doesn't work (with the same creds passed as row text this line works). I see following logs:
The following environment variables were removed by 'Only Keep Specified Environment Variables': ARTIFACTORY_PASSWD, ARTIFACTORY_USER, Branch, BUILD_CAUSE, ..., WORKSPACE, WORKSPACE_TMP Removing login credentials for artifacts.some_custom.com
Error: Cannot perform an interactive login from a non TTY device
Why my credentials were ignored/removed?
this error from https://plugins.jenkins.io/safe-batch-environment-filter/ plugin
in freestyle: not sure there is a way to do it, only add your job to exclude list in jenkins global config
in Jenkinsfile: you need to wrap your code with
keepEnv(['ARTIFACTORY_USER', 'ARTIFACTORY_PASSWD']) {
docker login artifacts.some_custom.com -u ${ARTIFACTORY_USER} -p ${ARTIFACTORY_PASSWD}
}
ps also need to add withCredentials
or what you use to get this creds to env variable
also jenkins has this feature: https://issues.jenkins.io/browse/JENKINS-62014 https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/137
assume you use freestyle jenkins job
in job config -> build steps -> execute shell -> advanced -> environment filters -> only keed specified environment variables
there you will find setting Environment variables to retain
you need to add your variables there
Whitespace separated, case insensitive list of environment variables that will be retained, i.e. not removed from the environment of this build step or reset to their default.
by default jenkins will remove variable