Bamboo is not creating a new branch plan automatically
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When using the "When new branch in the repository is created" option in the branch's plan configuration, the plan is not creating a new branch when one is created and pushed to the repository.
Environment
This behavior was observed on Bamboo Server version 8.2.1.
Diagnosis
If Bamboo is not creating a new branch automatically after creating a new branch and pushing it to the repository with the option "When new branch in the repository is created" enabled, verify the logs for the following message in the atlassian-bambo.log:
2022-05-11 01:08:55,711 WARN [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-57] [RestCallHelper] Failed to execute application link request. Server: https://bitbucket.localhost.com Method: POST Url: rest/api/latest/projects/<Plan_name>/repos/<repo_name>/commits/<commit_id>/builds
The location of the atlassian-bamboo.log
file can be viewed in Bamboo's System information under the Bamboo paths section.
Alternatively, run this query to verify a list of plans that have invalid linked repositories in their definition (you might need to adjust it according to your DBMS). If the plan affected shows up on the results for this query, you can go to the Solution section of this page.
SELECT B.FULL_KEY AS "PLAN_KEY",
VL.VCS_LOCATION_ID AS "REPO_ID",
VL.NAME AS "REPO_NAME"
FROM BUILD B
JOIN PLAN_VCS_LOCATION PVL ON B.BUILD_ID = PVL.PLAN_ID
JOIN VCS_LOCATION VL ON VL.VCS_LOCATION_ID = PVL.VCS_LOCATION_ID
WHERE BUILD_TYPE = 'CHAIN'
AND VL.PARENT_ID IS NOT NULL
AND VL.PARENT_ID NOT IN (SELECT VCS_LOCATION_ID FROM VCS_LOCATION WHERE MARKED_FOR_DELETION = FALSE);
Cause
The Repository being referenced was not the same, the original repository was either deleted or modified from the Linked Repositories page but the reference was kept on the Plan. Once the failing repository is manually replaced with the correct repository it works as expected.
Solution
This query should return a list of plans that have invalid linked repositories in their definition and the response expected will be similar to the below:
SELECT B.FULL_KEY AS "PLAN_KEY",
VL.VCS_LOCATION_ID AS "REPO_ID",
VL.NAME AS "REPO_NAME"
FROM BUILD B
JOIN PLAN_VCS_LOCATION PVL ON B.BUILD_ID = PVL.PLAN_ID
JOIN VCS_LOCATION VL ON VL.VCS_LOCATION_ID = PVL.VCS_LOCATION_ID
WHERE BUILD_TYPE = 'CHAIN'
AND VL.PARENT_ID IS NOT NULL
AND VL.PARENT_ID NOT IN (SELECT VCS_LOCATION_ID FROM VCS_LOCATION WHERE MARKED_FOR_DELETION = FALSE);
This query was tested on a MySQL database, it might need minor adjustments for other DBMS.
Outcome example:
Plan Key | Repository ID | Repository Name |
---|---|---|
PROJ-PLAN1 | 123456 | git-repository |
PROJ-PLAN2 | 123459 | bitbucket-repository |
Once you have this information, you will need to manually go to the Plans and replace the invalid repositories with valid ones.