Bitbucket Pipeline build setup fails due to submodule merge conflict

Abhisht Singh April 28, 2023
I am trying to trigger a bitbucket pipeline on PR merge. The idea is to run testing on every merge to "development-branch".

Our repository includes a sub-repository inside it. Once the PR is issue, tests are run through bitbucket-pipelines and they work perfectly.

However, when we merge the same PR to the "development-branch", the 'build setup' step of the pipeline fails (I don't know how much of this is under my control through the YAML configuration). Here is a dummy error log

 

HEAD is now at 908c7e319 Merged in brandLevelErrorReportDev (pull request #4043)
+ git config user.name bitbucket-pipelines
+ git config user.email <valid> 
+ git config push.default current
+ git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://localhost:29418/
+ git remote set-url origin http://bitbucket.org/$BITBUCKET_REPO_FULL_NAME
+ git reflog expire --expire=all --all
+ echo ".bitbucket/pipelines/generated" >> .git/info/exclude
+ CONFLICT_EXIT_CODE=3
+ git merge e81742c010ef --no-edit || exit $CONFLICT_EXIT_CODE
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
Auto-merging RandomService/RandomService.js
CONFLICT (content): Merge conflict in RandomService/RandomService.js
Failed to merge submodule RandomService/brand-files (not checked out)
CONFLICT (submodule): Merge conflict in RandomService/brand-files
Auto-merging RandomService/helpers/brand-functions.js
CONFLICT (content): Merge conflict in RandomService/helpers/brand-functions.js
Auto-merging RandomService/helpers/database-functions.js

Recursive merging with submodules currently only supports trivial cases.
Please manually handle the merging of each conflicted submodule.
This can be accomplished with the following steps:
 - come back to superproject and run:
      git add RandomService/<sub-repository folder>
   to record the above merge or update
 - resolve any other conflicts in the superproject
 - commit the resulting index in the superproject
Automatic merge failed; fix conflicts and then commit the result.

 

However, when I copy the "developement-branch" locally (with the merged PR) and run the following command,

git add RandomService/<sub-repository folder>

I get "nothing to commit, up to date"

I tried the suggested commands, and tried to improve the yml to have

clone: 
   depth: 5 # previously the value was "full"

The solutions have not worked

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 1, 2023

Hi @Abhisht Singh and welcome to the community!

Based on the log you shared here, this Pipelines build runs on a pull-requests definition of your bitbucket-pipelines.yml file. This type of pipeline merges the destination branch into your working branch before it runs (during the Build setup). If the merge fails (like in your build), the build stops.

You will need to first resolve the merge conflicts locally and then push back to the Bitbucket Cloud repo. You can find step-by-step instructions here:

In these instructions, replace <feature_branch> with the name of the source branch of the PR that triggered this build, and <destination_branch> with the name of the destination branch of the PR.

The depth of the clone is not relevant here, and the value you set for a pull-requests build will not be applied. A pull-requests build will always take a full-depth clone in order to merge.

Kind regards,
Theodora

Abhisht Singh May 1, 2023

Hi Theodora, 

 

Thank you for your quick reply. I just wanted to mention that I am unable to see any such merge conflict on my local. 

 

Infact, if I run a build based on the branch setting and trigger the same tests on my branch, it passes without issues. 

 

I would like to tell you more about my bitbucket-pipelines.yml file 

pipelines: 
branches:
destination-branch:
- step:
script:
- echo "Merge build" # build is successful

pull-requests:
destination-branch*: ## all PR with "destination-branch" prefix
- step:
size: 2x
name: "Running Tests"
script:
- echo "PR build" # build is successful during PR stage and
  # as soon as we merge the PR, the build is unsuccessful


This is super weird behaviour because I have still not been able to discover any merge conflicts locally. And if say there are merge conflicts, the builds are passing while the PR is not merged. 

on the merge-related commit fails the build. 

 

I hope I was able to describe my problem better. 

Thank you, 

Abhisht Singh 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 1, 2023

Hi @Abhisht Singh,

Thank you for sharing additional info.

Infact, if I run a build based on the branch setting and trigger the same tests on my branch, it passes without issues.

A build that runs based on a branches definition doesn't do any merge during Build setup. E.g. for a build that runs on this definition:

branches:
  destination-branch:

A Docker container will start and the branch named destination-branch will be cloned in the Docker container. This will happen during the Build setup. This kind of pipeline will run every time there are new commits on destination-branch (either because someone pushed, or because a PR was merged into destination-branch)


For the following definition:

pull-requests:
destination-branch*:

A Pipelines build will run when a PR is created with source branch a branch that matches destination-branch*, and every time the source branch of the PR gets updated. Please keep in mind that this won't get triggered when destination-branch* is the destination branch.

This type of Pipeline will start a Docker container, clone the source branch of the PR in the container, and then merge the PR's destination branch into the source branch. This is where the merge is happening when your Pipeline fails.


In order to resolve the conflicts locally, you need to attempt to pull (locally) the destination branch into the source branch. Please see all the steps in the link I shared (and make sure you have pulled the latest updates of the source branch).

 

Kind regards,
Theodora

Like Abhisht Singh likes this
dhob July 20, 2023

Sorry for hijacking this thread but we seem to have the exact same issue.

This type of Pipeline will start a Docker container, clone the source branch of the PR in the container, and then merge the PR's destination branch into the source branch. This is where the merge is happening when your Pipeline fails.

For us, this merge always seems to fail as soon as the target branch contains 1+ commits more than the source branch (= cannot be fast forwarded). When we do the merge locally or even use the "bitbucket pr merge" functionality, it works just fine.

Do we have a configuration issue (Git / Linux container)? Is it possible that LFS (which we have enabled) creates an issue in pipelines?

Thanks Daniel

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2023

Hi Daniel and welcome to the community!

I would like to ask if you could please create a new question about this via https://community.atlassian.com/t5/forums/postpage/board-id/bitbucket-questions and post the content of your Build Setup.

I don't know off the top of my head why your pipeline fails, we would need to investigate. It's better to have a separate question, as an existing question can become difficult to follow if we try to troubleshoot multiple users' issues.

If you don't feel comfortable sharing details publicly, you can also create a ticket with the support team which will be visible only to you and Atlassian staff. 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.

Kind regards,
Theodora

Like dhob likes this
dhob July 24, 2023

Thanks Theodora, will do!

Like # people like this

Suggest an answer

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

Atlassian Community Events