我有Jenkins声明性管道,想根据提供的参数签出一个分支
def envToBranch = [:]
envToBranch['dev'] = 'develop'
envToBranch['stg'] = 'stage'
envToBranch['prod'] = 'master'
pipeline {
parameters {
choice(name: 'ENV', choices: ['dev', 'stg', 'prod'], description: 'Application environment')
}
stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: '<how-to-access-mapping-here>']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'SparseCheckoutPaths', sparseCheckoutPaths:[[$class:'SparseCheckoutPath', path:'ansible/']]]
],
submoduleCfg: [],
userRemoteConfigs: [
[credentialsId: 'my-creds',
url: 'git@github.com:MyOrg/my-repo.git']
]])
}
}
}
}
那么我如何在checkout指令中访问映射?我可以在script
指令中执行相同的操作吗?