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

1 answer

0 votes
Ronald C_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 10, 2025

Hi @DEVOPS INLAKS 

Would it be possible for us to confirm what error you're getting when running the script?

Based on my initial look, there are a few changes and troubleshooting steps we can recommend, if the issue you referring was the folder not push to the DestRepo correctly:

# In SourceRepo
- echo "=== Copying folder to temp directory ==="
- mkdir -p /tmp/Folder-A_tmp
- cp -R Folder-A/* /tmp/Folder-A_tmp/
- ls -alh /tmp/Folder-A_tmp/

.....

# In DestRepo
- echo "=== Adding folder-A to DestRepo ==="
- mkdir -p Folder-A
- cp -R /tmp/Folder-A_tmp/. ./Folder-A
- ls -alh ./Folder-A/

 

Cheers,

Ronald

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