我在Bitbucket中配置了webhooks以捕获PR“创建”/“更新”事件,并在Jenkins上执行构建以在Bitbucket中提供构建状态。
在Jenkins中成功运行构建(我得到一个蓝色泡泡)后,它会通知Bitbucket有关构建状态并收到成功的响应。
Mar 15, 2018 3:55:07 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper sendBuildStatusNotification
INFO: This request was sent: {
"state": "SUCCESSFUL",
"key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"url": "http://XX.XX.XX.XX:8080/job/XXXXXX/16/",
"name": "XXXXXX #XX"
}
Mar 15, 2018 3:55:07 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper sendBuildStatusNotification
INFO: This response was received: {"key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "description": "", "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/XXXXXXXXXX/XXXXXXX"}, "html": {"href": "https://bitbucket.org/XXXXXXXXXX/XXXXXXX"}, "avatar": {"href": "https://bitbucket.org/XXXXXXXXXX/XXXXXXX/avatar/32/"}}, "type": "repository", "name": "XXXXXXX", "full_name": "XXXXXXXXXX/XXXXXXX", "uuid": "{XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX}"}, "url": "http://XX.XX.XX.XX:8080/job/XXXXXX/XX/", "links": {"commit": {"href": "https://api.bitbucket.org/2.0/repositories/XXXXXXXXXX/XXXXXXX/commit/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}, "self": {"href": "https://api.bitbucket.org/2.0/repositories/XXXXXXXXXX/XXXXXXX/commit/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/statuses/build/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}}, "refname": null, "state": "SUCCESSFUL", "created_on": "2018-03-15T03:55:07.857369+00:00", "commit": {"hash": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "type": "commit", "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/XXXXXXXXXX/XXXXXXX/commit/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}, "html": {"href": "https://bitbucket.org/XXXXXXXXXX/XXXXXXX/commits/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}}}, "updated_on": "2018-03-15T03:55:07.857429+00:00", "type": "build", "name": "XXXXXXX #XX"}
Mar 15, 2018 3:55:08 AM org.jenkinsci.plugins.workflow.job.WorkflowRun finish
INFO: PR-LGM #16 completed: SUCCESS
问题是,我在bitbucket上看到两个版本,一个是绿色勾选成功,另一个是永远待定(蓝色时钟)。
PR的后续更新,不断增加成功的构建,但一个构建将永远处于运行状态。
在jenkins上,我收到了这个错误。
Mar 15, 2018 3:55:08 AM hudson.model.listeners.RunListener report
WARNING: RunListener failed
java.lang.NullPointerException
at bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketRepository.setBuildStatus(BitbucketRepository.java:153)
at bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketBuilds.onCompleted(BitbucketBuilds.java:46)
at bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketBuildListener.onCompleted(BitbucketBuildListener.java:36)
at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:211)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:688)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$1400(WorkflowRun.java:143)
at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:1006)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1368)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:412)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
以下是管道作业的Jenkinsfile定义。
pipeline {
environment {
LINUX_NODE = ""
}
agent none
[...]
stages {
stage('Staging Code and Dependencies...') {
failFast true
parallel {
stage('Code Checkout') {
agent {
node { label 'linux_slave_machine' }
}
[...]
}
}
}
stage('Running...') {
failFast true
parallel {
stage('Running on Linux') {
agent {
node { label 'linux_slave_machine' }
}
steps {
deleteDir()
script {
LINUX_NODE = "${env.NODE_NAME}"
}
unstash 'code'
echo ("Printing for no reason!")
}
}
}
}
}
post {
success {
bitbucketStatusNotify(buildState: 'SUCCESSFUL')
node("${LINUX_NODE}") {
step([$class: 'WsCleanup'])
}
}
[...]
}
}
为冗长的问题道歉,但不知道我正在全面了解相关的内容。
非常感谢任何帮助。
答案 0 :(得分:0)
我创建了一些用于测试的旧工作,即使他们被禁用,也会让Bitbucket等待他们的构建状态通知。由于他们从未跑过,Bitbucket从未收到他们的身份。
嗟!!