我正在设置我的Jenkinsfile,以允许在为任何分支(仅在PR上)进行的每个位桶PR上进行测试。但是,创建PR时,该插件似乎针对每个分支构建。这是插件的错误吗?我正在使用Bitbucket Pull Request Builder插件1.4.30
我的触发条件如下
triggers{
- bitbucketpr(projectPath:'bitbucket.org/testrepo/django-db.git',
- cron:'* * * * *',
- credentialsId:'jenkins_pr_test',
- repositoryOwner:'testrepo',
- repositoryName:'django-db',
- branchesFilter:"*/dev",
- branchesFilterBySCMIncludes:false,
- ciKey:'jenkins',
- ciName:'jenkins',
- ciSkipPhrases:'',
- checkDestinationCommit:false,
- approveIfSuccess:false,
- cancelOutdatedJobs:true,
- commentTrigger:'')
- pollSCM('H/5 * * * *')
- }
我什至尝试以下内容仅针对特定分支进行构建,但该插件仍会构建所有分支。
- branchesFilter:"*/${BRANCH_NAME}"```
有什么想法吗?
我的阶段如下
stage('Build and Test Docker image') {
when { branch "${BRANCH_NAME}" }
steps {
script {
docker.withRegistry("${env.ECR_URL}", "ecr:us-east-1:ecrAccess") {
customImage = docker.build("${env.IMAGE_NAME}")
withCredentials([string(credentialsId: 'CODACY_TARGETDB_API', variable: 'CODACY_PROJECT_TOKEN')]) {
sh "curl -L \"https://github.com/docker/compose/releases/download/1.23.2/docker-compose-\$(uname -s)-\$(uname -m)\" -o docker-compose"
sh "chmod +x docker-compose"
sh "./docker-compose -f docker-compose-ci.yml up --exit-code-from web"
}
customImage.push()
}
}
}
答案 0 :(得分:0)
在Triggers块中,使用以下方式编辑projectPath
*/${sourceBranch}
它应该像这样:
bitbucketpr(projectPath:'*/${sourceBranch}',