How to pass credentials for username and password in the https Bitbucket Cloud repository URL for authentication via Bamboo script task
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
There may be instances where a script task in a Bamboo build plan is used to connect to a Bitbucket Cloud repository in order to push code changes or tags using git commands. This KB article explains how to configure the Bitbucket Cloud username and app_password credentials in the git commands used in the script task to authenticate the BB cloud repo via the https repo URL.
Environment
All supported versions of Bamboo
Solution
The sample script task below shows how to pass Bitbucket username and App password credentials in the git push command to authenticate the Bitbucket Cloud via the https URL:
export JOB_NAME=BAMBOO_BUILD
export BUILD_NUMBER=$(printf %05d ${bamboo.buildNumber})
cd ${bamboo.build.working.directory}
TAG="Test_Tag"
git push https://${bamboo.Bitbucket_Username}:${bamboo.APP_PASSWORD}@bitbucket.org/jcharupalli/test1.git "$TAG"
In the above git command, there are two options for passing the Bitbucket Cloud username and app password:
- Create plan variables for Bitbucket_Username and APP_PASSWORD in the Plan configuration > Actions > Configure Plan > Variables tab, then utilize those variables in the script task. You can also add these variables as global variables in case multiple plans want to use these variables.
- Alternatively, you can directly replace these with your Bitbucket Cloud username and app_password.
Please make sure to use the App password generated in Bitbucket Cloud for that specific username.