-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.60.3 on Linux Mint
I have a function in a shared library that uses the withCredentials plugin and is called from a Jenkins declarative pipeline. See the following experimental code:
def call(String name, String version) { withCredentials([usernamePassword(credentialsId: 'xxx', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { sh '''#!/bin/bash -xe echo "${USERNAME}:${PASSWORD}" echo \"${USERNAME}:${PASSWORD}\" echo "${name}:${version}" echo \"${name}:${version}\" ''' sh """#!/bin/bash -xe echo "${env.USERNAME}:${env.PASSWORD}" echo \"${env.USERNAME}:${env.PASSWORD}\" echo "${USERNAME}:${PASSWORD}" echo \"${USERNAME}:${PASSWORD}\" echo "${name}:${version}" echo \"${name}:${version}\" """ } }
I can't figure out how to get access to both, the function parameters and the variables from withCredentials in the same command. (This is just experimental code where I COULD split up the script. In the actual code I can't.) Using ''', the credentials are correct and the parameters are blank. Using """, the password, which can contain special characters, is shown in clear text (and cut), but the function parameters work fine. Is there a bug? How does this need to be done correctly?