image: ubuntu:latest
pipelines:
branches:
master:
- step:
name: Upload
script:
- sudo apt-get update && apt-get install -y openssh-client jq curl
- cat /opt/atlassian/pipelines/agent/ssh/id_rsa >> ec2_private_key.pem
- chmod 600 ec2_private_key.pem
- echo "Fetching modified files from Bitbucket API using diff endpoint"
- |
curl -s -H "Authorization: Bearer $API_TOKEN_BEARER" \
| jq -r '.values[0].hash' > latest_commit.txt
- COMMIT_HASH=$(cat latest_commit.txt)
- |
curl -s -H "Authorization: Bearer $API_TOKEN_BEARER" \
| grep '^+++ b' | awk '{print $2}' | sed 's/^b\///' > modified_files.txt
- echo "Modified files:"
- cat modified_files.txt
- while IFS= read -r file; do
scp -i ec2_private_key.pem -o StrictHostKeyChecking=no -r "$file" ubuntu@$EC2_HOST:$PATH"$file";
done < modified_files.txt
- ssh -i ec2_private_key.pem -o StrictHostKeyChecking=no ubuntu@$EC2_HOST "cd $PATH && sudo docker-compose up --build -d"
But in the build setup phase of the pipeline I get this error, so the image is not installed properly and I can't use any commands that come by defect in ubuntu.
This is the error in the build setup: