Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Merging dev and main as pipeline step

Libby Askew
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 6, 2024

I am using a bitbucket pipeline for testing and would like to have the following work flow: 

- A PR is merged into dev branch 

- Tests run in the pipeline on the dev branch 

- If the tests are successful, dev is automatically merged into main.

I am trying to merge dev into main using this step: 

 

name: Merge with Main

          image: atlassian/default-image:2

          script:

            - git fetch https://x-token-auth:$REPO_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git main

            - git fetch origin dev

            - git checkout dev

            - git log

            - git pull origin dev

            - git fetch origin main:main

            - git checkout main

            - git log

            - git merge dev

            - git push https://x-token-auth:$REPO_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git main


However this gives the error:

+ git merge dev

2
Auto-merging bitbucket-pipelines.ym

3
CONFLICT (add/add): Merge conflict in bitbucket-pipelines.yml
4 Automatic merge failed; fix the conflicts and then commit the result.

 

When I run these steps locally I am able to merge to two branches: 

Updating 03457968..78df9483 
Fast-forward bitbucket-pipelines.yml
41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)


What steps do I need to run to be able to successfully merge the two branches in the pipeline and why is there a discrepancy between running it locally and in the pipeline? 
Many thanks

 

 

 

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 2024

Hi Libby and welcome to the community!

The discrepancy may occur because the HEAD of the main branch, or that of dev branch, or both, are different in this specific Pipelines build from the ones in your local clone. This can happen if you haven't pulled the latest changes of dev and main locally, or if you have pulled them but the Pipelines build runs on older commits.

You can create a ticket with the support team and provide the URL of that Pipelines build, and the output of your local merge that you shared here, for further investigation regarding this discrepancy. You can create a ticket via https://support.atlassian.com/contact/#/, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product. When you are asked to provide the workspace URL, please make sure you enter the URL of the workspace that is on a paid billing plan to proceed with ticket creation.

 

The build in Pipelines is failing because of a merge conflict (changing the same line of a file on the two branches you are trying to merge):

Resolving a merge conflict in Pipelines cannot be done automatically, unless you provide a merge strategy in order to always keep either the version of the conflicted file(s) in the currently checked out branch, or the version of the conflicted file(s) on the branch you are merging from.

Would you like to do that? Or do you prefer the merge to fail in case of a merge conflict, so that you review and resolve the conflict manually, and then run another build?

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events