I have the following initial situation:
- I have a Docker container running Jenkins 2.379
- This Jenkins has the Bitbucket Server Integration and the Bitbucket Branch Sourch Plugin installed
- The connection to the Bitbucket server seems to work
- I also set up a multibranch pipeline that listens to the repository in the connected Bitbucket server instance
- And I have set the Scan Multibranch Pipeline Trigger to All pushes.
- Finally, it seems that Jenkins has correctly implemented the webhook in the corresponding Bitbucket project.
- Changes to some configurations of the multibranch pipeline trigger the scan process, which works properly. If there are changes in the code of the corresponding branch during a push, the build is triggered.
- Clicking the "Scan Multibranch Pipeline Now" button has the same result.
- But if I just push some code changes into a branch, nothing happens. My pipeline does not start automatically and no build process is started with the changes made.
Goal: Every push a developer does in a branch of this project should trigger the scan for new branches in Jenkis and the build process for new branches or those where something has changed.
CodePudding user response:
I have found the problem/solution. As I said, my Jenkins runs in a Docker container and is hosted locally on my PC (localhost:8080).
Through the credentials, the path from Jenkins into Bitbucket worked and so did creating the webhook. However, for this webhook, the Bitbucket server plugin entered its address (localhost:8080). So now when a push into a Bitbucket repo happens, this webhook was triggered on Bitbucket's localhost:8080 (so presumably Bitbucket itself and not Jenkins).
The solution was now quite simple. I used a tool called ngrok to make my localhost:8080 (on which Jenkins runs) accessible via a URL from the internet. I then only had to store this URL in Jenkis in system configurations and adapt the webhook in my Bitbucket repository.