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:
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?
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.
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:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okey, i finally reproduced your issue. I will investigate it and notify you later
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.