Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

duplicate a folder in source repo a to another destination repo on bitbucket using bitbucke pipeline

DEVOPS INLAKS
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 26, 2025

SourceRepo consist of folder-A, folder-B and folder-c. I need to duplicate folder-A to another repository on Bitbucket called DestRepo using BitBucket pipeline. Both repository only have one branch named main.

I have written below pipeline but it is failing

 

pipelines:
default:
- step:
name: Duplicate Folder-A from SourceRepo → DestRepo (SSH)
image: atlassian/default-image:latest
script:
- set -euo pipefail

- echo "=== Setting up SSH keys ==="
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts

- echo "=== Cloning SourceRepo repository ==="
- git clone git@bitbucket.org:${SourceRepo}.git
- cd SourceRepo

- echo "=== Copying folder to temp directory ==="
- mkdir -p /tmp/Folder-A_tmp
- cp -R Folder-A /tmp/Folder-A_tmp

- cd ..
- echo "=== Cloning DestRepo repository ==="
- git clone git@bitbucket.org:${DestRepo}.git DestRepo
- cd DestRepo

- echo "=== Adding folder-A to DestRepo ==="
- cp -R /tmp/Folder-A_tmp ./Folder-A
- git config user.email "DEVOPS@mycompanyla.COM"
- git config user.name "devops"
- git add Folder-A
- git commit -m "Add folder-A from SourceRepo repository"
- git push

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events