[Feb 2019 update: All repos are now switched to using the http origin by default]
We’ve started rolling out an improved experience for committing back to your repository from within Bitbucket Pipelines - pushing back over http with zero git configuration.
Previously, you were able to commit back to you repository using SSH, which required manual configuration and management of SSH keys, often a time consuming and error prone process. Now you can commit back with zero configuration or management of keys.
This feature will be enabled by default for all new accounts, as well as those that haven’t pushed back using the SSH origin in any owned repositories within the past 6 weeks.
Pushing back over http from Bitbucket Pipelines is the preferred option, and will enable you to adopt new features of Bitbucket in the future.
https://bitbucket.org/bitbucketpipelines/commit-a-new-file
pipelines:
default:
- step:
script:
- echo "Made a change in build ${BITBUCKET_BUILD_NUMBER}" >> changes.txt
- git add changes.txt
- git commit -m "[skip ci] Updating changes.txt with latest build number."
- git push
https://bitbucket.org/bitbucketpipelines/pushing-a-tag
pipelines:
default:
- step:
script:
- echo "Made a change in build ${BITBUCKET_BUILD_NUMBER}" >> changes.txt
- git add changes.txt
- git commit -m "Updating changes.txt with latest build number."
- git tag -am "Tagging for release ${BITBUCKET_BUILD_NUMBER}" release-${BITBUCKET_BUILD_NUMBER}
- git push origin release-${BITBUCKET_BUILD_NUMBER}
Previously, the git ‘origin’ was configured to use SSH for authenticating with Bitbucket, with the git origin set to ‘git@bitbucket.org/<<your account>>/<<your repo>>.git’. To commit back, you had to configure a git username, email, SSH public/private key pair, and have either pipelines pass the keys to git, or configure it yourself, manually.
By default, all repositories that haven’t recently used SSH to push will now have the git origin set to ‘http://bitbucket.org<<your account>>/<<your repo>>’, and will take advantage of fully managed authentication. We send git requests to Bitbucket via a proxy which runs as part of your pipeline. We inject an auth token using a Git proxy that runs along side your main build container, into all Bitbucket git requests which are send via https to Bitbucket, allowing you to seamlessly and securely perform git operations.
We don’t want anyone currently using SSH to be impacted by this change so we’ve added all accounts that have recently used SSH to an exclusion list. In this case, all repositories under your account will continue to use the SSH origin until February 1st 2019, when we plan to switch ‘origin’ from SSH to the new http mechanism.
Pushing back using the http origin to repositories where branch permissions are enabled is not yet supported. In this scenario you will need to manually configure git to use an alternate authentication method, providing the necessary credentials that allow you push back to the repository. For these situations we recommend pushing over http using OAuth based authentication. See our docs for details on how to set up alternative authentication methods.
You will need to manually configure the git origin until you've been removed from the exclusion list. To do this, execute the following command from within your bitbucket-pipelines.yml file to set origin to use http:
https://bitbucket.org/bitbucketpipelines/git-auth-use-http
git remote set-url origin ${BITBUCKET_GIT_HTTP_ORIGIN}
Once you've been removed from the list, you can revert this change.
To continue using SSH, you need to manually set the origin to SSH by executing the following command from within your bitbucket-pipelines.yml file:
https://bitbucket.org/bitbucketpipelines/git-auth-ssh-configured-in-ui/
git remote set-url origin ${BITBUCKET_GIT_SSH_ORIGIN}
If you are no longer relying on the SSH origin and wish to switch to http, you can request to get off the exclusion list by submitting a request. Once this is done, the http origin will become the default for your account, and you can remove any manual configuration.
We’ve introduced 2 new variables that can be referenced from within pipelines, to contain the http and SSH origin urls. We recommend using these where the origin needs to be passed through to scripts or other tools that are invoked in your pipeline, or if you want to switch between http and SSH:
${BITBUCKET_GIT_HTTP_ORIGIN}
${BITBUCKET_GIT_SSH_ORIGIN}
If you are not using the git CLI provided by Pipelines, we recommend configuring origin using the ${BITBUCKET_GIT_HTTP_ORIGIN} variable. If using the http origin, you will also need to configure your git client to use a proxy. The proxy url is: http://localhost:29418.
Linette
Experience Design Manager
7 accepted answers
56 comments