如何使用Rsync正确编写Bitbucket管道?

发布于 2025-01-30 23:39:36 字数 1655 浏览 4 评论 0原文

我正在编写一个Bitbucket管道,以将我的Angular项目部署到EC2实例。这是使用Rsync的管道。

image: node:12.18.3
pipelines:
    branches:
      dev:
      - step:
         name: Build Test Environment
         caches:
           - node
         script:
           - npm install
           - npm run build-qa
         artifacts:
            - dist/qa/**
         deployment: test
      - step:
              name: Deploy
              trigger: manual
              script:
                - apt-get update && apt-get install -y rsync
                - ssh-keyscan -H $SERVER >> ~/.ssh/known_hosts
                - cd $BITBUCKET_CLONE_DIR/dist/qa
                - ls
                - rsync -v -e ssh . $SSH_USER@$SERVER:/var/www/html/myproject
                - echo "Deployment is done...!"

但这给了我这个错误。

+ rsync -v -e ssh . $SSH_USER@$SERVER:/var/www/html/myproject
skipping directory .
rsync: link_stat "/opt/atlassian/pipelines/agent/build/dist/qa/$SSH_USER@myip" failed: No such file or directory (2)
rsync: link_stat "/opt/atlassian/pipelines/agent/build/dist/qa/ecdsa-sha2-nistp256" failed: No such file or directory (2)
rsync: change_dir#3 "/opt/atlassian/pipelines/agent/build/dist/qa//AAAAE2VjZHNhLXNtYTItbmlzdHAyNTwAAqAIbmlzdHAyNsYAAABBBGqKvzLI7IolhgM1ZEfol3VuJX4CX6jzqSyM6AzUgPbpyERywu/7U/SioMc/SLeJyfhYnWAJVApt8oOsqIjLqDg=:/var/www/html/myproject" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(713) [Receiver=3.1.2]

我尝试了很多东西来找到解决方案,甚至使用Rsync-Deploy管道尝试过,但是它还给出了以上错误的错误,有人可以帮助我正确编写此管道以完成我的要求吗?

I am writing a bitbucket pipeline to deploy my angular project to the ec2 instance. This is my pipeline using rsync.

image: node:12.18.3
pipelines:
    branches:
      dev:
      - step:
         name: Build Test Environment
         caches:
           - node
         script:
           - npm install
           - npm run build-qa
         artifacts:
            - dist/qa/**
         deployment: test
      - step:
              name: Deploy
              trigger: manual
              script:
                - apt-get update && apt-get install -y rsync
                - ssh-keyscan -H $SERVER >> ~/.ssh/known_hosts
                - cd $BITBUCKET_CLONE_DIR/dist/qa
                - ls
                - rsync -v -e ssh . $SSH_USER@$SERVER:/var/www/html/myproject
                - echo "Deployment is done...!"

But this is giving me this error.

+ rsync -v -e ssh . $SSH_USER@$SERVER:/var/www/html/myproject
skipping directory .
rsync: link_stat "/opt/atlassian/pipelines/agent/build/dist/qa/$SSH_USER@myip" failed: No such file or directory (2)
rsync: link_stat "/opt/atlassian/pipelines/agent/build/dist/qa/ecdsa-sha2-nistp256" failed: No such file or directory (2)
rsync: change_dir#3 "/opt/atlassian/pipelines/agent/build/dist/qa//AAAAE2VjZHNhLXNtYTItbmlzdHAyNTwAAqAIbmlzdHAyNsYAAABBBGqKvzLI7IolhgM1ZEfol3VuJX4CX6jzqSyM6AzUgPbpyERywu/7U/SioMc/SLeJyfhYnWAJVApt8oOsqIjLqDg=:/var/www/html/myproject" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(713) [Receiver=3.1.2]

I tried a lot to find out a solution to this I even tried with the rsync-deploy pipe but it also gives the same above error can someone help me to write this pipeline correctly to get my requirement done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月静好 2025-02-06 23:39:36

似乎与这里的问题相似 https://sererverfault.com/questions/questions/questions/363555/ WHY-is-rshync-skipping-the-main-directory

  • 您可能内部有文件夹,要递归将其递归包含在转移中,
  • 您需要将源更改为./,因此它是一个文件夹

,作为奖励

  • 您可以/应该与路径一起运行LS,而与Rsync相同,而不是CD进入那里。记住尾随 /

Seems similar to the issue here https://serverfault.com/questions/363555/why-is-rsync-skipping-the-main-directory

  • you probably have folders inside you want to recursively include in the transfer
  • you need to change the source to ./ so it gets it is a folder

and as a bonus

  • you can/should just run ls with the path, and same with rsync, and not cd into there. Remember the trailing /
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文