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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.