Jenkins Git 参数插件 branchFilter 正则表达式
Jenkins Git Parameter Plugin branchFilter regex
我在此处使用 Git 参数插件 (0.9.12) 用于 Jenkins 声明性管道,如下所示。 params.branchName
的输出是 master,对于我的情况,输出需要 origin/master。
有没有办法做到这一点?如何添加从 params.brancName.
获取 origin/master 输出
parameters {
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'branchName', type: 'PT_BRANCH'
}
stages {
stage('Git clone and environment setup') {
steps{
git branch: "${params.branchName}", credentialsId: 'xxx', url: 'https://git.xxxx.git'
echo 'Git paramater...' + params.branchName
// Git paramater...master. ->> **Which I need is origin/master**
}
}
stage ('Run Tests for Dev ') {
when {
beforeAgent true
expression { params.branchName == "origin/development"}
}
这里是要构建的分支的配置。
试试这个:
parameters {
gitParameter name: 'branchName',
type: 'PT_BRANCH',
defaultValue: 'master'
}
stages {
stage('Git clone and environment setup') {
steps{
script {
echo "Git paramater is ${params.branchName}"
git branch: "${params.branchName}", credentialsId: 'xxx', url: 'https://git.xxxx.git'
}
}
}
stage ('Run Tests for Dev ') {
when {
beforeAgent true
expression { "${params.branchName}" == "origin/development"}
}
}
我试过同样的代码。它对我有用:
我在此处使用 Git 参数插件 (0.9.12) 用于 Jenkins 声明性管道,如下所示。 params.branchName
的输出是 master,对于我的情况,输出需要 origin/master。
有没有办法做到这一点?如何添加从 params.brancName.
获取 origin/master 输出parameters {
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'branchName', type: 'PT_BRANCH'
}
stages {
stage('Git clone and environment setup') {
steps{
git branch: "${params.branchName}", credentialsId: 'xxx', url: 'https://git.xxxx.git'
echo 'Git paramater...' + params.branchName
// Git paramater...master. ->> **Which I need is origin/master**
}
}
stage ('Run Tests for Dev ') {
when {
beforeAgent true
expression { params.branchName == "origin/development"}
}
这里是要构建的分支的配置。
试试这个:
parameters {
gitParameter name: 'branchName',
type: 'PT_BRANCH',
defaultValue: 'master'
}
stages {
stage('Git clone and environment setup') {
steps{
script {
echo "Git paramater is ${params.branchName}"
git branch: "${params.branchName}", credentialsId: 'xxx', url: 'https://git.xxxx.git'
}
}
}
stage ('Run Tests for Dev ') {
when {
beforeAgent true
expression { "${params.branchName}" == "origin/development"}
}
}
我试过同样的代码。它对我有用: