question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

‘Jenkinsfile’ not found Skipped - error using webhooks

See original GitHub issue

Since version 2.9.10 (works with 2.9.9) there seem to be a problem when using webhooks: Pull requests are still recognized, but with a “Jenkinsfile not found” error in Multibranch Pipeline Events and no job triggered.

Running “Scan Multibranch Pipeline Now” manually triggers the PR jobs correctly.

It looks like https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/445 could be causing this behavior and especially https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/445/commits/39abb5eb2ab244a6ce81442a7cdd5bf2ebb422e6, but that’s just a wild guess (still debugging).

Version report

Jenkins and plugins versions report:

Jenkins: 2.289.3
OS: Linux - 3.10.0-1160.24.1.el7.x86_64
---
workflow-api:2.46
jsch:0.1.55.2
workflow-job:2.41
credentials:2.5
jaxb:2.3.0.1
workflow-step-api:2.24
git-client:3.9.0
git-server:1.10
token-macro:266.v44a80cf277fd
workflow-support:3.8
xunit:3.0.2
antisamy-markup-formatter:2.1
durable-task:1.38
matrix-project:1.19
git:4.8.1
ant:1.11
ssh-credentials:1.19
gradle:1.37.1
plain-credentials:1.7
credentials-binding:1.27
display-url-api:2.3.5
timestamper:1.13
workflow-cps-global-lib:2.21
ace-editor:1.1
workflow-durable-task-step:2.39
resource-disposer:0.16
ws-cleanup:0.39
nodejs:1.4.0
pam-auth:1.6
pipeline-milestone-step:1.3.2
jquery-detached:1.2.1
jackson2-api:2.12.4
docker-commons:1.17
jdk-tool:1.5
pipeline-graph-analysis:1.11
script-security:1.78
pipeline-rest-api:2.19
cloudbees-folder:6.16
bouncycastle-api:2.21
docker-workflow:1.26
structs:1.23
scm-api:2.6.5
build-timeout:1.20
workflow-scm-step:2.13
workflow-cps:2.93
mailer:1.34
pipeline-input-step:2.12
pipeline-stage-step:2.5
handlebars:3.0.8
momentjs:1.1.1
branch-api:2.6.5
pipeline-stage-view:2.19
pipeline-build-step:2.14
publish-over:0.22
workflow-multibranch:2.26
pipeline-model-api:1.9.1
pipeline-model-extensions:1.9.1
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.4
workflow-basic-steps:2.23
pipeline-stage-tags-metadata:1.9.1
external-monitor-job:1.7
publish-over-ssh:1.22
pipeline-model-definition:1.9.1
build-blocker-plugin:1.7.7
workflow-aggregator:2.6
command-launcher:1.6
windows-slaves:1.8
ssh-slaves:1.32.0
matrix-auth:2.6.8
ldap:2.7
email-ext:2.83
javadoc:1.6
maven-plugin:3.12
dashboard-view:2.17
config-file-provider:3.8.1
rebuild:1.32
docker-plugin:1.2.2
cobertura:1.16
htmlpublisher:1.25
ssh-agent:1.23
docker-java-api:3.1.5.2
jacoco:3.3.0
run-condition:1.5
conditional-buildstep:1.4.1
ssh:2.6.1
parameterized-trigger:2.41
jquery:1.12.4-1
build-pipeline-plugin:1.5.8
envinject-api:1.7
envinject:2.4.0
built-on-column:1.1
jenkins-multijob-plugin:1.36
git-parameter:0.9.13
pipeline-utility-steps:2.8.0
variant:1.4
build-user-vars-plugin:1.7
h2-api:1.4.199
lockable-resources:2.11
ansible:1.1
jobConfigHistory:2.28.1
code-coverage-api:1.4.0
forensics-api:1.2.1
dtkit-api:3.0.0
analysis-model-api:10.2.5
trilead-api:1.0.13
sonar:2.13.1
warnings-ng:9.4.0
mercurial:2.15
bitbucket:1.1.29
pipeline-maven:3.10.0
testng-plugin:1.15
greenballs:1.15.1
chucknorris:1.4
pipeline-npm:0.9.2
Office-365-Connector:4.15.0
authorize-project:1.4.0
font-awesome-api:5.15.3-4
handy-uri-templates-2-api:2.1.8-1.0
terraform:1.0.10
shelve-project-plugin:3.2
login-theme:1.1
theme-manager:0.6
simple-theme-plugin:0.7
strict-crumb-issuer:2.1.0
bootstrap4-api:4.6.0-3
audit-trail:3.10
golang:1.4
job-dsl:1.77
saml:2.0.7
ansicolor:1.0.0
checks-api:1.7.2
data-tables-api:1.10.25-2
popper-api:1.16.1-2
bootstrap5-api:5.0.2-1
caffeine-api:2.9.1-23.v51c4e2c879c8
plugin-util-api:2.4.0
junit:1.51
snakeyaml-api:1.29.1
echarts-api:5.1.2-3
mask-passwords:3.0
basic-branch-build-strategies:1.3.2
dark-theme:0.0.12
**cloudbees-bitbucket-branch-source:2.9.10**
sshd:3.1.0
configuration-as-code:1.51
popper2-api:2.5.4-3
jquery3-api:3.6.0-2
extended-read-permission:3.2
cloudbees-disk-usage-simple:0.10
bitbucket-scm-trait-commit-skip:0.4.0
  • What Operating System are you using (both controller, and any agents involved in the problem)?
OS: Linux
Agents: also Linux but not involved

Reproduction steps

  • Create a repo in a project in Bitbucket with a webhook on PRs

  • Fork the project repo to your private space

  • Create a new branch in private fork with minimal changes

  • Create a PR src:private-repo dst:project-repo

  • Receive webhook in Jenkins

Results

Expected result:

[Thu Aug 05 12:17:56 UTC 2021] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent CREATED event from IP ⇒ https://JENKINS_URL/bitbucket-scmsource-hook/notify with timestamp Thu Aug 05 12:17:56 UTC 2021 Connecting to https://BITBUCKET_URL using TECHNICAL_USER Repository type: Git Looking up PROJ/e-root for branches Checking branch master from PROJ/e-root

1 branches were processed Looking up PROJ/e-root for pull requests Checking PR-21 from ~PRIV/e-root and branch part1 ‘Jenkinsfile’ found Met criteria Scheduled build for branch: PR-21

1 pull requests were processed (query completed) [Thu Aug 05 12:18:00 UTC 2021] com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent CREATED event from IP ⇒ https://JENKINS_URL/bitbucket-scmsource-hook/notify with timestamp Thu Aug 05 12:17:56 UTC 2021 processed in 3.6 sec

Actual result:

[Thu Aug 05 12:52:39 UTC 2021] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent CREATED event from IP ⇒ https://JENKINS_URL/bitbucket-scmsource-hook/notify with timestamp Thu Aug 05 12:52:39 UTC 2021 Connecting to https://BITBUCKET_URL using TECHNICAL_USER Repository type: Git Looking up PROJ/e-root for branches Checking branch master from PROJ/e-root

1 branches were processed Looking up PROJ/e-root for pull requests Checking PR-22 from ~PRIV/e-root and branch testing ‘Jenkinsfile’ not found Skipped

1 pull requests were processed [Thu Aug 05 12:52:40 UTC 2021] com.cloudbees.jenkins.plugins.bitbucket.hooks.NativeServerPullRequestHookProcessor$HeadEvent CREATED event from IP ⇒ https://JENKINS_URL/bitbucket-scmsource-hook/notify with timestamp Thu Aug 05 12:52:39 UTC 2021 processed in 0.98 sec

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sjjarvicommented, Jan 14, 2022

After taking a deeper look at the code, we discovered that the enhancement introduced in 2.9.10 skips some API calls that are required in order to make commit hashes from private forks be visible to the main repo.

The two API calls are:

/pull-requests/{pullRequestId}/merge

Comments found in the code near this call:

// This is required for Bitbucket Server to update the refs/pull-requests/*references
// See https://community.atlassian.com/t5/Bitbucket-questions/Change-pull-request-refs-after-Commit-instead-of-after-Approval/qaq-p/194702#M6829

and

/pull-requests/{pullRequestId}/changes

This appears to be required as of Bitbucket 7.x. See note #2 in the table at the top of this page: https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/docs/USER_GUIDE.adoc

In versions <= 2.9.9, PRs were retrieved in this manner: https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/2bdc16ebef04d566fe616bb2a22f2389535f9963/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java#L559, which ultimately makes this call for each PR: https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/2bdc16ebef04d566fe616bb2a22f2389535f9963/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java#L339 The setupPullRequest() method invokes the /merge and /changes API.

In 2.9.10 and above, even though we only want to go after the relevant PRs from the event (vs. getting all of them from the repo), we still need these calls to happen for the PR associated with the event. Without those calls, the call to check for the Jenkinsfile at the corresponding commit hash fails. e.g.

Checking PR-1 from ~MYFORK/some-repo-name and branch develop
      ‘Jenkinsfile’ not found
    Skipped

We’ve implemented a change that sends the PRs retrieved from this line https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/2bdc16ebef04d566fe616bb2a22f2389535f9963/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java#L556 through a similar code path that ultimately calls setupPullRequest(). Testing so far looks good and we’ll submit a PR for this. We are using Bitbucket Server v7.6.7 and tend to stay up to date with the latest Jenkins LTS.

0reactions
MarkusSchoelzelcommented, Apr 19, 2022

Many thanks to all involved and especially to @sjjarvi! ❤️

Issue is fixed by 5a2d6a23c01d8507043a52862f74f71b3facee03.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Jenkinsfile' not found when PR triggers a build with Bitbucket
I'm having an issue where webhooks from PRs are properly triggering, but failing to build with 'Jenkinsfile' not found errors.
Read more >
Jenkins: Github webhook does not trigger any job
First build made after setting webhook correctly must succeed completely for the changes to take effect and for webhooks to start working. This ......
Read more >
How to skip a build after a "git push" done by a Jenkinsfile
The "git push" will trigger the push webhook in GitHub that makes a call to ... these options are available in the Jenkins...
Read more >
Is there a way to use a Jenkinsfile from a git-submodule in a ...
The result in "Scan Multibranch Pipeline Log" was a Communication error for url response. The Jenkinsfile was not found, and so no build...
Read more >
GitHub: Webhook Troubleshooting - CloudBees Support
Available from Manage Jenkins > GitHub Hooks Problems Console only and if only any of Automatic Webhooks has not been setup in GitHub....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found