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

The pipe bitbucket-pipe-release:5.0.1 fails to commit changes to the main branch

Christof Koegler _Gaims GmbH_ September 26, 2022

I am using the Bitbucket pipe bitbucket-pipe-release:5.0.1 to push a custom pipe to our managed repository. Both pushing and pulling succeeds, and the custom pipe works fine.

Recently, I added a step to my pipeline which will, in addition to releasing the custom pipe, create a tag, update the version, and commit all changes to the master branch, as per bitbucket-pipe-release's documentation. This branch only triggers whenever the committed .env file changes. When I run the step, however, it fails to push the changes to the main branch:

Screenshot from 2022-09-26 13-36-49.png

Here is the step definition:

push: &push
step:
name: Push and tag new version
runs-on:
- gaims
image: python:3.10
script:
- APP_VERSION=$(cat .env | grep -oP "APP_VERSION=[/']?\K[\d/.]*")
- pipe: docker://bitbucketpipelines/bitbucket-pipe-release:5.0.1
variables:
REGISTRY_USERNAME: $REGISTRY_USER
REGISTRY_PASSWORD: $REGISTRY_PWD
IMAGE: $REGISTRY_URL/bitbucket/$BITBUCKET_REPO_SLUG
REGISTRY_URL: $REGISTRY_URL
VERSION: $APP_VERSION
BITBUCKET_BRANCH: main
CHANGELOG: 'false'
condition:
changesets:
includePaths:
- ".env"
services:
- docker

pipelines
:
default:
- <<: *test
- <<: *push-dev
branches:
develop:
- <<: *test
- <<: *push
main:

The main branch is indeed called 'main' and I have not restricted read/write access to it. Why does the pipeline fail?

1 answer

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 30, 2022

Hi @Christof Koegler _Gaims GmbH_ .Thanks for your question.

Try manually run all git commands firstly on local machine to see if any errors, then on pipeline without using pipe to see if any errors and notify us with the result.

Regards, Igor.

Christof Koegler _Gaims GmbH_ October 4, 2022

Hi @Igor Stoyanov . Thanks for getting back to me.

I do not exactly know how this is implemented in the pipe, so it is hard to reproduce locally. However, I have adjusted the step to merge the changes made by the pipe (updating the version in README.md and pipe.yml) into the main branch 'manually' after the pipe has run:

 

push: &push
step:
name: Push and tag new version
runs-on:
- gaims
image: python:3.10
clone:
depth: full
script:
- APP_VERSION=$(cat .env | grep -oP "APP_VERSION=[/']?\K[\d/.]*")
- pipe: docker://bitbucketpipelines/bitbucket-pipe-release:5.0.1
variables:
REGISTRY_USERNAME: $REGISTRY_USER
REGISTRY_PASSWORD: $REGISTRY_PWD
IMAGE: $REGISTRY_URL/bitbucket/$BITBUCKET_REPO_SLUG
REGISTRY_URL: $REGISTRY_URL
VERSION: $APP_VERSION
CHANGELOG: 'false'
- git pull
- git checkout main
- git merge --no-ff -m "Merge version $APP_VERSION into main branch [skip ci]" $BITBUCKET_BRANCH
- git push
condition:
changesets:
includePaths:
- ".env"
services:
- docker

This works and achieves the desired end result. However, it was my understanding that the pipe provides that functionality as well. From the pipe docs:

Screenshot from 2022-10-04 13-09-41.png

I understood this to mean that the pipe will push the changes made to the branch specified under BITBUCKET_BRANCH. Or am I misreading this?

 

Thanks

Chris

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 5, 2022

Your error was here:

git push -u origin main

 

Usually this means you don't have main branch. To ensure that main branch exists i suggested you to manually push to main branch.

Also all git commands presented on your provided screenshot. 

I can't see any problems with your yml configuration, all should work.

And yes, if you want to release into main branch, you should provide this

BITBUCKET_BRANCH: main

into variables.

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 5, 2022

Okey, i finally reproduced your issue. I will investigate it and notify you later

Christof Koegler _Gaims GmbH_ October 6, 2022

Great, thanks.

Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2022

Hi @Christof Koegler _Gaims GmbH_ 

We have investigated the issue and found that it could happened when you have a setup with parameters for a branch different than build based on the branch build runs. Documentation is updated accordingly.

So, we don't recommend to provide a BITBUCKET_BRANCH variable for the pipe. It will be available by default in the build and in the setup during git clone.

 

Best regards,
Oleksandr Kyrdan

Christof Koegler _Gaims GmbH_ October 31, 2022


Thanks @Oleksandr Kyrdan  for investigating and updating the documentation accordingly.

I will stick to pushing the files into the main branch 'manually' as described in my previous answer.

Best regards
Chris

Suggest an answer

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

Atlassian Community Events