Skip to content

Instantly share code, notes, and snippets.

@mig82
Last active May 31, 2017 17:42
Show Gist options
  • Save mig82/ab6c0ee42881555de203ffa9fb06c774 to your computer and use it in GitHub Desktop.
Save mig82/ab6c0ee42881555de203ffa9fb06c774 to your computer and use it in GitHub Desktop.
A Jenkins job that passes a user and password and a secret file to another job
properties([
parameters([
[
$class: 'CredentialsParameterDefinition',
name: 'GIT_CREDENTIALS',
credentialType: 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl',
defaultValue: params.GIT_CREDENTIALS?params.GIT_CREDENTIALS:'',
description: 'Credentials for Github.',
required: true
],
[
$class: 'CredentialsParameterDefinition',
name: 'ANDROID_KEYSTORE_FILE',
credentialType: 'org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl',
defaultValue: params.ANDROID_KEYSTORE_FILE?params.ANDROID_KEYSTORE_FILE:'',
description: 'The Android keystore (.jks or .keystore) file',
required: false
]
])
])
stage('echo'){
echo(params.GIT_CREDENTIALS)
echo(params.ANDROID_KEYSTORE_FILE)
}
stage('call B'){
build(
job: 'jobB',
propagate: true,
wait: true,
parameters: [
[$class: "CredentialsParameterValue", name: "GIT_CREDENTIALS", value: "${params.GIT_CREDENTIALS}"],
[$class: "CredentialsParameterValue", name: "ANDROID_KEYSTORE_FILE", value: "${params.ANDROID_KEYSTORE_FILE}"]
]
)
}
@mig82
Copy link
Author

mig82 commented May 31, 2017

Passing credential parameters between jenkins jobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment