我有这个 bitbucket 管道:图像:ubuntu:latestpipelines:分支:master:-步骤:名称:上传脚本:-apt-get update && apt-get insta...
我有这个 bitbucket 管道:
image: ubuntu:latest
pipelines:
branches:
master:
- step:
name: Upload
script:
- 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" \
"https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_FULL_NAME/commits/master" \
| jq -r '.values[0].hash' > latest_commit.txt
- COMMIT_HASH=$(cat latest_commit.txt)
- |
curl -s -H "Authorization: Bearer $API_TOKEN_BEARER" \
"https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_FULL_NAME/diff/$COMMIT_HASH" \
| 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"
这与我在另一个存储库中拥有的另一个管道非常相似,并且已经可以正常工作。但是,执行管道时似乎未正确安装映像。在构建设置中,我收到此错误:
使用的图像:构建:docker.io/library/ubuntu@sha256:bash:dircolors:未找到命令
在 apt-get 行中我收到此错误:
- apt-get update && apt-get install -y openssh-client jq curlbash:apt-get:未找到命令
使用命令 find( https://linuxize.com/post/how-to-find-files-in-linux-using-the-command-line/ ),您可以在每个目录和子目录中查找文件并对其执行命令。
find -L . -name "*ATAC*" -exec mv {} path-to-your-directory/ \