您好,我最近说过要学习管道,有人可以帮我编写用于选择参数化分支结帐的管道吗,如果我结帐master分支,然后部署到某些S3位置,否则,如果dev分支到其他位置。我已经尝试过,但是失败了,任何人都可以帮助我。pipeline {
agent any
parameters {
choice(
name: 'BRANCH',
choices: 'Development\nrelease/release_QA\nmaster',
description: 'Selct the branch to deploy to repective Airflow')
}
stages {
stage('checkout code') {
steps {
git(url: 'https://bitbucket.nike.com/scm/something.git', branch: '${params.BRANCH}', credentialsId: '4db2-aec4-7d5e86c4ff4b', changelog: true)
sh 'ls -al'
}
}
}
}
我遇到以下错误,
+refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/${params.BRANCH}^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/${params.BRANCH}^{commit} # timeout=10
> git rev-parse origin/${params.BRANCH}^{commit} # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
还可以帮助我如何编写分支然后上演的故事..............
答案 0 :(得分:1)
将${params.BRANCH}
用双引号引起来,或者仅使用BRANCH
都可以。
如果我检出master分支,然后部署到某个S3位置,否则,如果dev分支到某个其他位置
pipeline {
agent any
parameters {
choice(
name: 'BRANCH',
choices: 'Development\nrelease/release_QA\nmaster',
description: 'Selct the branch to deploy to repective Airflow')
}
stages {
stage('checkout code') {
steps {
git(url: 'https://bitbucket.nike.com/scm/something.git', branch: "${params.BRANCH}", credentialsId: '4db2-aec4-7d5e86c4ff4b', changelog: true)
}
}
stage('Deploy to S3') {
when {
expression {
BRANCH == 'master'
}
}
// Deploy to S3
}
stage('Deploy elsewhere') {
when {
expression {
BRANCH == 'Development'
}
}
// Deploy elsewhere
}
}
}