I am publishing a website on Bitbucket Cloud.
I have followed the documentation and am manually pushing the static files (html) to bitbucket.io and am able to see those pages.
Now instead of manually pushing the files, I want to automate it with bitbucket pipeline.
I have a separate repo where the pipeline generates the folder containing the static html files. I want to push this folder into the bitbucket.io repo as part of the pipeline step.
I tried to add git clone commands on the bitbucket-pipeline.yaml file and then copy from one repo to another but something or the other keeps failing.
Is there any documentation that can guide me how this can be done?
Hi Raj,
You are able to push from one repository to another by making use of our Repository Access Token (RAT) feature to grant the necessary privilege scope over HTTPS.
Essentially, you would follow the steps below - where RepoA is your source repository and RepoB is the target repository where you wish to push the file/folder:
WritetoRepo:
- step:
name: "Write to another repo"
script:
- git clone https://x-token-auth:$ACCESSTOKEN@bitbucket.org/workspaceID/test.bitbucket.io.git
- cp -R foldername test.bitbucket.io
- cd test.bitbucket.io
- git config user.email alphanumericstring@bots.bitbucket.org
- git add -A
- git commit -a -m "Committing folder"
- git push
NOTE: You can use the bots.bitbucket.org email address that was provided when generating the access token to reflect in the commit history that it was committed by a bot, or you can simply use your own email address if you would prefer for your user to show here instead
Please attempt the above and let me know how it goes - I intend on adapting this into our documentation to assist future users :)
Cheers!
- Ben (Bitbucket Cloud Support)
Apologies for the late reply Ben.
The solution that you provided worked. Thank you.
It will be a good addition to your documentation because some users may have similar ask as in my case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted]
Awesome news! I have already created documentation since and included instructions for SSH as well:
https://confluence.atlassian.com/bbkb/push-to-another-repository-in-pipelines-1277624367.html
Thanks,
Ben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.