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