bitbucket-branch-source-plugin icon indicating copy to clipboard operation
bitbucket-branch-source-plugin copied to clipboard

Webhooks trigger, but do not build

Open wickkidd opened this issue 3 years ago • 7 comments

Version report

Bitbucket Server: v7.5.1

Jenkins and plugins versions report:

Jenkins: 2.263.3
OS: Linux - 4.4.0-1117-aws
---
ace-editor:1.1
authentication-tokens:1.4
ant:1.11
antisamy-markup-formatter:2.1
handlebars:1.1.1
apache-httpcomponents-client-4-api:4.5.13-1.0
config-file-provider:3.7.0
blueocean-autofavorite:1.2.4
bouncycastle-api:2.18
gradle:1.36
javadoc:1.6
blueocean-bitbucket-pipeline:1.24.4
credentials-binding:1.24
blueocean-commons:1.24.4
email-ext:2.81
external-monitor-job:1.7
blueocean-events:1.24.4
credentials:2.3.15
blueocean-core-js:1.24.4
display-url-api:2.3.4
blueocean-dashboard:1.24.4
blueocean-config:1.24.4
docker-commons:1.17
blueocean-display-url:2.4.1
favorite:2.3.2
docker-workflow:1.25
blueocean-git-pipeline:1.24.4
branch-api:2.6.2
jira:3.2
blueocean-github-pipeline:1.24.4
blueocean-i18n:1.24.4
git-client:3.6.0
blueocean-jira:1.24.4
script-security:1.76
git-server:1.9
blueocean-jwt:1.24.4
build-timeout:1.20
blueocean-personalization:1.24.4
cloudbees-bitbucket-branch-source:2.9.7
cloudbees-folder:6.15
jsch:0.1.55.2
blueocean-pipeline-api-impl:1.24.4
junit:1.48
blueocean-pipeline-editor:1.24.4
command-launcher:1.5
blueocean-pipeline-scm-api:1.24.4
durable-task:1.35
blueocean-rest-impl:1.24.4
git:4.5.2
blueocean-rest:1.24.4
github-api:1.122
blueocean-web:1.24.4
github-branch-source:2.9.5
github:1.33.0
blueocean:1.24.4
jdk-tool:1.4
conditional-buildstep:1.4.1
handy-uri-templates-2-api:2.1.8-1.0
sonar:2.13
structs:1.21
htmlpublisher:1.25
subversion:2.14.0
icon-shim:2.0.3
testng-plugin:1.15
jackson2-api:2.12.1
jenkins-design-language:1.24.4
timestamper:1.11.8
jquery-detached:1.2.1
workflow-cps:2.87
jquery:1.12.4-1
mapdb-api:1.0.9.0
token-macro:2.13
variant:1.4
matrix-auth:2.6.5
windows-slaves:1.7
matrix-project:1.18
workflow-aggregator:2.6
maven-plugin:3.8
workflow-api:2.41
mercurial:2.12
workflow-job:2.40
ssh-credentials:1.18.1
momentjs:1.1.1
ws-cleanup:0.38
jaxb:2.3.0.1
pubsub-light:1.13
pipeline-build-step:2.13
resource-disposer:0.14
pipeline-github-lib:1.0
scm-api:2.6.4
metrics:4.0.2.7
pipeline-graph-analysis:1.10
nodejs:1.3.11
mailer:1.32.1
pipeline-input-step:2.12
pipeline-milestone-step:1.3.2
pam-auth:1.6
pipeline-model-api:1.8.4
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.8.4
ldap:1.26
workflow-support:3.7
slack:2.45
pipeline-model-definition:1.8.4
pipeline-stage-view:2.19
plain-credentials:1.7
pipeline-model-extensions:1.8.4
workflow-basic-steps:2.23
workflow-cps-global-lib:2.17
pipeline-npm:0.9.2
sse-gateway:1.24
run-condition:1.5
pipeline-rest-api:2.19
ssh-slaves:1.31.5
popper-api:1.16.1-1
kubernetes-credentials:0.8.0
jjwt-api:0.11.2-8.82737cbfa6f5
bitbucket-push-and-pull-request:2.7.1
pipeline-utility-steps:2.6.1
plugin-util-api:1.7.0
git-parameter:0.9.13
extensible-choice-parameter:1.7.0
generic-webhook-trigger:1.72
workflow-multibranch:2.22
okhttp-api:3.14.9
extended-choice-parameter:0.82
parameterized-trigger:2.39
lockable-resources:2.10
snakeyaml-api:1.27.0
workflow-step-api:2.23
monitoring:1.86.0
bootstrap4-api:4.6.0-1
kubernetes-client-api:4.13.2-1
jquery3-api:3.5.1-2
http_request:1.8.27
kubernetes:1.29.0
font-awesome-api:5.15.2-1
checks-api:1.5.0
trilead-api:1.0.13
workflow-durable-task-step:2.37
job-dsl:1.77
echarts-api:4.9.0-3
workflow-scm-step:2.11
atlassian-bitbucket-server-integration:2.1.2
Result: [Plugin:ace-editor, Plugin:authentication-tokens, Plugin:ant, Plugin:antisamy-markup-formatter, Plugin:handlebars, Plugin:apache-httpcomponents-client-4-api, Plugin:config-file-provider, Plugin:blueocean-autofavorite, Plugin:bouncycastle-api, Plugin:gradle, Plugin:javadoc, Plugin:blueocean-bitbucket-pipeline, Plugin:credentials-binding, Plugin:blueocean-commons, Plugin:email-ext, Plugin:external-monitor-job, Plugin:blueocean-events, Plugin:credentials, Plugin:blueocean-core-js, Plugin:display-url-api, Plugin:blueocean-dashboard, Plugin:blueocean-config, Plugin:docker-commons, Plugin:blueocean-display-url, Plugin:favorite, Plugin:docker-workflow, Plugin:blueocean-git-pipeline, Plugin:branch-api, Plugin:jira, Plugin:blueocean-github-pipeline, Plugin:blueocean-i18n, Plugin:git-client, Plugin:blueocean-jira, Plugin:script-security, Plugin:git-server, Plugin:blueocean-jwt, Plugin:build-timeout, Plugin:blueocean-personalization, Plugin:cloudbees-bitbucket-branch-source, Plugin:cloudbees-folder, Plugin:jsch, Plugin:blueocean-pipeline-api-impl, Plugin:junit, Plugin:blueocean-pipeline-editor, Plugin:command-launcher, Plugin:blueocean-pipeline-scm-api, Plugin:durable-task, Plugin:blueocean-rest-impl, Plugin:git, Plugin:blueocean-rest, Plugin:github-api, Plugin:blueocean-web, Plugin:github-branch-source, Plugin:github, Plugin:blueocean, Plugin:jdk-tool, Plugin:conditional-buildstep, Plugin:handy-uri-templates-2-api, Plugin:sonar, Plugin:structs, Plugin:htmlpublisher, Plugin:subversion, Plugin:icon-shim, Plugin:testng-plugin, Plugin:jackson2-api, Plugin:jenkins-design-language, Plugin:timestamper, Plugin:jquery-detached, Plugin:workflow-cps, Plugin:jquery, Plugin:mapdb-api, Plugin:token-macro, Plugin:variant, Plugin:matrix-auth, Plugin:windows-slaves, Plugin:matrix-project, Plugin:workflow-aggregator, Plugin:maven-plugin, Plugin:workflow-api, Plugin:mercurial, Plugin:workflow-job, Plugin:ssh-credentials, Plugin:momentjs, Plugin:ws-cleanup, Plugin:jaxb, Plugin:pubsub-light, Plugin:pipeline-build-step, Plugin:resource-disposer, Plugin:pipeline-github-lib, Plugin:scm-api, Plugin:metrics, Plugin:pipeline-graph-analysis, Plugin:nodejs, Plugin:mailer, Plugin:pipeline-input-step, Plugin:pipeline-milestone-step, Plugin:pam-auth, Plugin:pipeline-model-api, Plugin:pipeline-stage-step, Plugin:pipeline-stage-tags-metadata, Plugin:ldap, Plugin:workflow-support, Plugin:slack, Plugin:pipeline-model-definition, Plugin:pipeline-stage-view, Plugin:plain-credentials, Plugin:pipeline-model-extensions, Plugin:workflow-basic-steps, Plugin:workflow-cps-global-lib, Plugin:pipeline-npm, Plugin:sse-gateway, Plugin:run-condition, Plugin:pipeline-rest-api, Plugin:ssh-slaves, Plugin:popper-api, Plugin:kubernetes-credentials, Plugin:jjwt-api, Plugin:bitbucket-push-and-pull-request, Plugin:pipeline-utility-steps, Plugin:plugin-util-api, Plugin:git-parameter, Plugin:extensible-choice-parameter, Plugin:generic-webhook-trigger, Plugin:workflow-multibranch, Plugin:okhttp-api, Plugin:extended-choice-parameter, Plugin:parameterized-trigger, Plugin:lockable-resources, Plugin:snakeyaml-api, Plugin:workflow-step-api, Plugin:monitoring, Plugin:bootstrap4-api, Plugin:kubernetes-client-api, Plugin:jquery3-api, Plugin:http_request, Plugin:kubernetes, Plugin:font-awesome-api, Plugin:checks-api, Plugin:trilead-api, Plugin:workflow-durable-task-step, Plugin:job-dsl, Plugin:echarts-api, Plugin:workflow-scm-step, Plugin:atlassian-bitbucket-server-integration]
  • What Operating System are you using (both controller, and any agents involved in the problem)?
controller: Linux - 4.4.0-1117-aws
agent: Linux - 4.14.198-152.320.amzn2.x86_64

Reproduction steps

Steps

1: Configured jenkins with a Team/Project using defaults 2: Filtered the Team/Project down to a single repo testapp (until I get builds working properly from webhooks) 2: Filtered out building based on branch indexing with the exception of 3 named, long running/main branches (which do build correctly from indexing)

Additional (relevant) Jenkins configuration:

  • Team/Project with defaults
  • Call Changes api enabled
  • Manage hooks enabled
  • Webhook implementation native

Results

Expected result:

For the job to build as a result of the webhook firing (branch PR-14 based on the associated PR in this particular case)

Actual result:

The webhook fires successfully (http 200 in bitbucket > webhook details > Pull request opened > last success link).

For a new PR (pr:opened):

[Tue Mar 30 21:07:54 UTC 2021] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent CREATED event from 127.0.0.1 ⇒ http://localhost:8080/bitbucket-scmsource-hook/notify with timestamp Tue Mar 30 21:07:54 UTC 2021
Connecting to https://my-redacted-bitbucket-url.com using jenkins2/****** (jenkins2-stash)
Repository type: Git
Looking up EXP/testapp for branches
Checking branch test-team-5 from EXP/testapp
Checking branch test-team-4 from EXP/testapp
Checking branch test-team-3 from EXP/testapp
Checking branch test-team-1 from EXP/testapp
Checking branch develop from EXP/testapp
Checking branch test-webhook from EXP/testapp
Checking branch more-readme-changes from EXP/testapp
Checking branch pfm-2565-3 from EXP/testapp
Checking branch foo from EXP/testapp
Checking branch master from EXP/testapp

  10 branches were processed
Looking up EXP/testapp for pull requests
Checking PR-14 from EXP/testapp and branch test-team-5
      ‘Jenkinsfile’ found
    Met criteria
Did not schedule build for branch: PR-14

  1 pull requests were processed (query completed)
[Tue Mar 30 21:07:55 UTC 2021] com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent CREATED event from 127.0.0.1 ⇒ http://localhost:8080/bitbucket-scmsource-hook/notify with timestamp Tue Mar 30 21:07:54 UTC 2021 processed in 0.62 sec

For an updated PR (pr:from_ref_updated):

[Mon Apr 05 14:51:36 UTC 2021] com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent UPDATED event from 127.0.0.1 ⇒ http://localhost:8080/bitbucket-scmsource-hook/notify with timestamp Mon Apr 05 14:51:35 UTC 2021 processed in 0.86 sec
[Mon Apr 05 20:03:53 UTC 2021] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent UPDATED event from 127.0.0.1 ⇒ http://localhost:8080/bitbucket-scmsource-hook/notify with timestamp Mon Apr 05 20:03:53 UTC 2021
Connecting to https://my-redacted-bitbucket-url.com using jenkins2/****** (jenkins2-stash)
Repository type: Git
Looking up EXP/testapp for branches
Checking branch test-team-5 from EXP/testapp
Checking branch test-team-4 from EXP/testapp
Checking branch test-team-3 from EXP/testapp
Checking branch test-team-1 from EXP/testapp
Checking branch develop from EXP/testapp
Checking branch test-webhook from EXP/testapp
Checking branch more-readme-changes from EXP/testapp
Checking branch pfm-2565-3 from EXP/testapp
Checking branch foo from EXP/testapp
Checking branch master from EXP/testapp

  10 branches were processed
Looking up EXP/testapp for pull requests
Checking PR-14 from EXP/testapp and branch test-team-5
      ‘Jenkinsfile’ found
    Met criteria
Changes detected: PR-14 (null → 18945d39a483aad7c3d6421e3356579ab2e018dc+fb8fdf269c877139b0aeff2f6a90cd8f62ad06cd)
Did not schedule build for branch: PR-14

  1 pull requests were processed (query completed)
[Mon Apr 05 20:03:54 UTC 2021] com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent UPDATED event from 127.0.0.1 ⇒ http://localhost:8080/bitbucket-scmsource-hook/notify with timestamp Mon Apr 05 20:03:53 UTC 2021 processed in 0.8 sec

Notes:

While "Met criteria" was stated for branch PR-14 for both events, according to jobs/Brian\'s\ Test\ Team\ Project/jobs/testapp/indexing/events.log it still read "Did not schedule build for branch: PR-14."

This seems nearly identical to the issue @rnkhouse had here https://github.com/jenkinsci/bitbucket-branch-source-plugin/issues/315#issuecomment-638293537 with the main differences (afaik) being that the branch in question for my issue is based on a PR and the versions of things are a bit newer.

I did my best to compile the relevant information based on other issues here, stack, the interwebs at large, etc... If I missed anything, please let me know. My initial thought is that there might be a setting somewhere that I've made incorrectly since it claims "Met criteria" and "Changes detected" (with the actual sha of the change in the case of an update), but then states that it did not schedule a build. Any direction would be greatly appreciated. Thanks.

wickkidd avatar Apr 05 '21 17:04 wickkidd

We are experience this issue as well:

  • Bitbucket v7.8.1
  • Bitbucket Branch Source v2.9.9

aajimal avatar Sep 01 '21 01:09 aajimal

The "Did not schedule build for branch:" message seems to come from MultiBranchProject.scheduleBuild. So ParameterizedJobMixin.scheduleBuild2 presumably returned null.

If you click "Build Now" on the pull request, does it build then?

ParameterizedJobMixIn.ParameterizedJob.isBuildable checks ((Job) this).isHoldOffBuildUntilSave(), which might somehow have been left in the wrong state. Can you check that via the Script Console?

KalleOlaviNiemitalo avatar Sep 01 '21 12:09 KalleOlaviNiemitalo

@KalleOlaviNiemitalo I am facing the same issue. When I click Build now, The project builds.

Even though I have set the Automatic trigger to discover PR-.* and develop branch. Whenever I create a new PR the job doesn't trigger, It also doesn't trigger when there are push events to the develop branch, Not sure how to go about it ?

@bitwiseman Can you share your thoughts on this issue.

Thilaknath avatar Sep 13 '21 19:09 Thilaknath

@wickkidd Do you have a solution for this ?

Thilaknath avatar Sep 13 '21 19:09 Thilaknath

Manually triggering the build has helped but it is obviously not scalable. We have also found that deleting the PR and re-creating it has helped.

So it does seem that maybe there is something amiss in the PR updated hook when fired (i.e. when a PR is opened and commits are added over time). However, this does not seem to happen in every case of updated PRs.

aajimal avatar Oct 21 '21 21:10 aajimal

@wickkidd Do you have a solution for this ?

Yes. We're moving to github workflows/actions https://docs.github.com/en/actions/learn-github-actions 💪

As others have suggested, manual builds work as do builds triggered via push through the webhook (which is what we're currently using). The problem with using push is that there are many times when a dev simply wants to save their work by pushing up a branch they don't intend to have built and perhaps never even merged, yet it will be built anyway. This causes undesired resource usage which limits how many resources are available for builds we do want and it costs money as well.

Despite moving on from jenkins for our use case, I'm still interested in seeing PR triggers work in jenkins as I'm sure it and I will cross paths again sooner than I'd think. FWIW, most of the issues I've ever had with jenkins aren't actually with the core software, but rather with the plugins. Not knocking the generous plugin authors. Just noting where the issues tend to be found.

wickkidd avatar Nov 10 '21 15:11 wickkidd

Is this still an issue with the current release? (context: https://github.com/jenkinsci/bitbucket-branch-source-plugin/issues/527#issuecomment-986227458)

lifeofguenter avatar Dec 05 '21 13:12 lifeofguenter

If someone is encountering this issue, when you see:

Did not schedule build for branch: PR-...

One important item to check is at the organization folder level: the configuration entry Automatic branch project triggering -> Branch names to build automatically. Make sure this regex is either .* or has PR-\d+ inside of the regex.

rkivisto avatar Feb 09 '23 22:02 rkivisto