jenkinsci / scm-filter-branch-pr-plugin

A Jenkins plugin for Pipeline Multibranch filtering based on pull request destination branches in addition to matching the branch itself.
https://plugins.jenkins.io/scm-filter-branch-pr/
MIT License
3 stars 8 forks source link

Filter by name including PRs destined for this branch doesn't trigger by PR in BitBucket server #25

Closed AssafKatz3 closed 1 year ago

AssafKatz3 commented 1 year ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.401.2 OS: Linux - 5.15.0-67-generic Java: 11.0.19 - Ubuntu (OpenJDK 64-Bit Server VM) --- analysis-model-api:11.3.0 ansicolor:1.0.2 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:159.v25b_c67cd35fb_ apache-httpcomponents-client-4-api:4.5.14-150.v7a_b_9d17134a_5 artifactory:3.18.6 atlassian-bitbucket-server-integration:3.5.0 authentication-tokens:1.53.v1c90fd9191a_b_ bitbucket-approve:1.0.3 bitbucket-build-status-notifier:1.4.2 blueocean-bitbucket-pipeline:1.27.5 blueocean-commons:1.27.5 blueocean-core-js:1.27.5 blueocean-dashboard:1.27.5 blueocean-jira:1.27.5 blueocean-jwt:1.27.5 blueocean-pipeline-api-impl:1.27.5 blueocean-pipeline-scm-api:1.27.5 blueocean-rest:1.27.5 blueocean-rest-impl:1.27.5 blueocean-web:1.27.5 bootstrap5-api:5.3.0-1 bouncycastle-api:2.29 branch-api:2.1122.v09cb_8ea_8a_724 build-pipeline-plugin:1.5.8 build-timeout:1.31 caffeine-api:3.1.6-115.vb_8b_b_328e59d8 checks-api:2.0.0 cloudbees-bitbucket-branch-source:825.va_6a_dc46a_f97d cloudbees-folder:6.815.v0dd5a_cb_40e0e command-launcher:100.v2f6722292ee8 commons-lang3-api:3.12.0-36.vd97de6465d5b_ commons-text-api:1.10.0-36.vc008c8fcda_7b_ config-file-provider:952.va_544a_6234b_46 configuration-as-code:1670.v564dc8b_982d0 credentials:1271.v54b_1c2c6388a_ credentials-binding:604.vb_64480b_c56ca_ crowd2:4.0.0 data-tables-api:1.13.5-1 display-url-api:2.3.7 dtkit-api:3.0.2 durable-task:510.v324450f8dca_4 echarts-api:5.4.0-5 email-ext:2.99 emailext-template:1.5 external-monitor-job:207.v98a_a_37a_85525 favorite:2.4.2 folder-properties:1.2.1 font-awesome-api:6.4.0-2 forensics-api:2.3.0 generic-webhook-trigger:1.86.4 git:5.2.0 git-client:4.4.0 git-parameter:0.9.19 git-server:99.va_0826a_b_cdfa_d github:1.37.1 github-api:1.314-431.v78d72a_3fe4c3 github-branch-source:1728.v859147241f49 gradle:2.8.1 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.31 instance-identity:173.va_37c494ec4e5 ionicons-api:56.v1b_1c8c49374e ivy:2.5 jackson2-api:2.15.2-350.v0c2f3f8fc595 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javadoc:233.vdc1a_ec702cff javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.8-1 jdk-tool:66.vd8fa_64ee91b_d jenkins-design-language:1.27.5 jersey2-api:2.40-1 jfrog:1.4.0 jira:3.10 jira-steps:2.0.165.v8846cf59f3db jjwt-api:0.11.5-77.v646c772fddb_0 job-dsl:1.84 job-import-plugin:3.6 jobConfigHistory:1227.v7a_79fc4dc01f jquery:1.12.4-1 jquery3-api:3.7.0-1 jsch:0.2.8-65.v052c39de79b_2 junit:1217.v4297208a_a_b_ce ldap:682.v7b_544c9d1512 mailer:457.v3f72cb_e015e5 matrix-auth:3.1.10 matrix-project:789.v57a_725b_63c79 maven-plugin:3.22 mercurial:1260.vdfb_723cdcc81 mina-sshd-api-common:2.10.0-69.v28e3e36d18eb_ mina-sshd-api-core:2.10.0-69.v28e3e36d18eb_ multiple-scms:0.8 nodejs:1.6.0 nodelabelparameter:1.12.0 okhttp-api:4.11.0-145.vcb_8de402ef81 parameterized-trigger:2.46 parasoft-findings:10.6.2 pipeline-build-step:496.v2449a_9a_221f2 pipeline-github-lib:42.v0739460cda_c4 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:656.va_a_ceeb_6ffb_f7 pipeline-input-step:468.va_5db_051498a_4 pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2144.v077a_d1928a_40 pipeline-model-definition:2.2144.v077a_d1928a_40 pipeline-model-extensions:2.2144.v077a_d1928a_40 pipeline-multibranch-defaults:2.1 pipeline-rest-api:2.33 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2144.v077a_d1928a_40 pipeline-stage-view:2.33 pipeline-utility-steps:2.16.0 plain-credentials:143.v1b_df8b_d3b_e48 plugin-util-api:3.3.0 popper2-api:2.11.6-2 powershell:2.0 prism-api:1.29.0-7 publish-over:0.22 publish-over-ssh:1.25 pubsub-light:1.17 python:1.3 resource-disposer:0.22 scm-api:676.v886669a_199a_a_ scm-filter-branch-pr:77.vf2b_85e1970d5 script-security:1251.vfe552ed55f8d snakeyaml-api:1.33-95.va_b_a_e3e47b_fa_4 ssh:2.6.1 ssh-agent:333.v878b_53c89511 ssh-credentials:305.v8f4381501156 ssh-slaves:2.877.v365f5eb_a_b_eec ssh-steps:2.0.65.vd26b_5b_9b_de4d ssh2easy:1.4 sshd:3.303.vefc7119b_ec23 stashNotifier:1.28 structs:324.va_f5d6774f3a_d timestamper:1.25 token-macro:359.vb_cde11682e0c trilead-api:2.84.v72119de229b_7 variant:59.vf075fe829ccb vs-code-metrics:1.7 warnings-ng:10.2.0 windows-slaves:1.8.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1241.v4edc8b_44933b_ workflow-basic-steps:1017.vb_45b_302f0cea_ workflow-cps:3717.va_180a_fe9d3cd workflow-durable-task-step:1247.v7f9dfea_b_4fd0 workflow-job:1316.vd2290d3341a_f workflow-multibranch:756.v891d88f2cd46 workflow-scm-step:415.v434365564324 workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:839.v35e2736cfd5c ws-cleanup:0.45 xunit:3.1.2 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux

Reproduction steps

  1. Create webhook in internal BitBucket by Bitbucket Server Integration

  2. Create a multi-branch pipeline

  3. In behaviors:

    • Discover branches
    • Filter by name including PRs destined for this branch (with regular expression): Branch regular expression=devel
  4. Both options in Bitbucket webhook trigger as selected

Expected Results

Both devel and any PR in BitBucket will trigger the build

Actual Results

Only changes in devel trigger

Anything else?

I checked and the webhook is actually called but ignored.

jonesbusy commented 1 year ago

Hi,

Please include log (controller and multibranch scan log).

I'm not familiar at all with atlassian-bitbucket-server-integration.

But I can confirm this work with cloudbees-bitbucket-branch-source with the auto-registration of the webhook.

Regards,

AssafKatz3 commented 1 year ago

Hi, The log of scan is:

Started by user admin jenkins  (admin_jenkins)
[Tue Jul 25 14:46:39 UTC 2023] Starting branch indexing...
 > git rev-parse --resolve-git-dir /opt/tomcat/.jenkins/caches/git-2edb2f5855db92a82a8383eace9a6d8c/.git # timeout=10
Setting origin to http://***.***.***.***:***/scm/arils/***********.git
 > git config remote.origin.url http://***.***.***.***:***/scm/arils/***********.git # timeout=10
Fetching & pruning origin...
Listing remote references...
 > git config --get remote.origin.url # timeout=10
 > git --version # timeout=10
 > git --version # 'git version 2.34.1'
using GIT_ASKPASS to set credentials jira
 > git ls-remote -h -- http://***.***.***.***:***/scm/arils/***********.git # timeout=10
Fetching upstream changes from origin
 > git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials jira
 > git fetch --tags --force --progress --prune -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
Checking branches...
  Checking branch devel
      ‘.Jenkinsfile’ found
    Met criteria
No changes detected: devel (still at 7e144f23b451d6986c56d9f318b2fb05c9079ffe)
Processed 64 branches
[Tue Jul 25 14:46:40 UTC 2023] Finished branch indexing. Indexing took 0.39 sec
Finished: SUCCESS

The relevant section of Jenkins logs (after I disabled a regular pipeline:

Bitbucket - did not accept the request
Jul 25, 2023 2:41:39 PM INFO com.atlassian.bitbucket.jenkins.internal.http.HttpRequestExecutorImpl handleError
Bitbucket - did not accept the request
Jul 25, 2023 3:01:12 PM INFO com.atlassian.bitbucket.jenkins.internal.http.HttpRequestExecutorImpl handleError
Bitbucket - did not accept the request

The version of Atlassian Bitbucket is v7.17.0.

Thanks

jonesbusy commented 1 year ago

Just to be clear, removing the traits/behavior make the webhook working or not ?

Because I don't see anything relevant to the scm-filter-branch-pr-plugin here.

AssafKatz3 commented 1 year ago

Just to be clear, removing the traits/behavior make the webhook working or not ?

Because I don't see anything relevant to the scm-filter-branch-pr-plugin here.

Hi, Yes, it makes them work (it found all branches and runs them). Thanks

samrocketman commented 1 year ago

Does the Jira plugin use jenkins.scm.api.mixin.ChangeRequestSCMHead to decorate pull requests? That's how this plugin detects them (provided by the generic scm-api plugin).

samrocketman commented 1 year ago

I think this is a bug in the other plugin https://github.com/search?q=repo%3Ajenkinsci%2Fatlassian-bitbucket-server-integration-plugin%20ChangeRequestSCMHead&type=code

A code search does not turn up any implementation. Compare this to the GitHub branch source plugin https://github.com/search?q=repo%3Ajenkinsci%2Fgithub-branch-source-plugin%20ChangeRequestSCMHead&type=code

samrocketman commented 1 year ago

@AssafKatz3 it looks like there's already bug reports for the atlassian bitbucket server integration plugin https://issues.jenkins.io/browse/JENKINS-66581?jql=resolution%20is%20EMPTY%20and%20component%3D25721%20and%20text%20~%20%22ChangeRequestSCMHead%22

I am closing this as not a bug for this plugin. I recommend commenting on those other issues if you have new information to add and/or you can vote in the upper right corner that you're affected.

cc @jonesbusy

samrocketman commented 1 year ago

https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/tree/feature/JENKINS-66581-PR-support branch appears to be active but not yet merged.

AssafKatz3 commented 1 year ago

Hi, So, unfortunately, this issue is indeed a bug, but it originates from a different plugin :-( Best regards

samrocketman commented 1 year ago

@AssafKatz3 you do have a workaround if you really needed it. You could clone that plugin, checkout the branch JENKINS-66581-PR-support and build it.

You need: OpenJDK 11 and Apache Maven 3.8.

# clone and checkout
git clone -b feature/JENKINS-66581-PR-support https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin.git
cd atlassian-bitbucket-server-integration-plugin/

# compile
mvn clean package

# upload the HPI file to a test Jenkins instance to try it out
ls target/*.hpi

Your other option is to wait for that feature to be released. If you have an Atlassian support contract I would also recommend opening an Atlassian support case and referencing the Jenkins issues I gave you. Leverage your support contract to your benefit since it is Atlassian employees controlling the release and development of that plugin.