我的目标是触发基于位桶推送的管道作业。我现在正在测试Webhook,并且未触发生成。詹金斯的日志显示了一些错误,但我不明白:
有人可以解释为什么jenkins pipeline job
(又名SCMTriggerItem
)找不到SCM
吗?
环境:
https://myurl.com/jenkins/bitbucket-hook/
这是错误(source code from Bitbucket plugin):
Oct 14, 2020 10:50:16 AM FINE com.cloudbees.jenkins.plugins.BitbucketJobProbe
Considering candidate job hello-world-server
Oct 14, 2020 10:50:16 AM FINE com.cloudbees.jenkins.plugins.BitbucketJobProbe
Considering to poke hello-world-server
Oct 14, 2020 10:50:16 AM WARNING com.cloudbees.jenkins.plugins.BitbucketJobProbe triggerMatchingJobs
No SCM configuration was found!
在line 45中,插件循环遍历作业(Jenkins.getInstance().getAllItems(Job.class)
)。我假设“工作”是下面定义的工作(pipelineJob('hello-world-server')
)。在line 60中,插件尝试将作业投射到SCMTriggerItem。在line 65中,插件尝试从触发项中获取SCM,但未找到任何SCM。显然,我的工作定义已设置为cpsScm->scm->git
。我希望这足够了。还有其他需要完成的工作吗?还是bitbucket插件不适用于管道作业?
我的工作定义:
jobs:
- script: >
pipelineJob('hello-world-server') {
// jobdsl v1.77 deprecates triggers. Here is the migration wiki:
// https://github.com/jenkinsci/job-dsl-plugin/wiki/Migration
properties{
pipelineTriggers{
triggers{
bitbucketPush()
}
}
}
definition {
cpsScm {
scm {
git {
remote {
url('https://hijoe@bitbucket.org/hijoe/hello-world-server.git')
credentials('jenkins_bitbucket_password')
}
branches('master','develop')
scriptPath('Jenkinsfile')
extensions { }
}
}
}
}
}
我的Jenkins文件:
pipeline {
agent any
environment{
}
stages {
stage('Build'){
steps{
echo '### Building to be done'
}
}
stage('Testing'){
steps{
echo '### Testing to be done'
}
}
stage('Deploy') {
steps {
echo '### Release to be done'
}
}
}
}
更新:
升级到Bitbucket 1.1.27后,它可以工作了。我收到一个新错误,即没有匹配的存储库,但可以通过指定overrideUrl
来解决此问题:
triggers{
bitbucketPush{
overrideUrl('https://bitbucket.org/hijoe/hello-world-server')
}
}