unix - CircleCI 运行多行命令

标签 unix ssh circleci circleci-2.0

摘自 CircleCI 配置文件:

deploy:
  machine:
    enabled: true
  steps:
    - run:
        name: AWS EC2 deploy
        command: |
          ssh -o "StrictHostKeyChecking no" ubuntu@xxx.xxx.xxx.xxx "cd ~/circleci-aws; git pull; npm i; npm run build; pm2 restart build/server

如何将命令分成多行?尝试了以下语法,但它只运行第一个命令:
deploy:
  machine:
    enabled: true
  steps:
    - run:
        name: Deploy
        command: |
          ssh -o StrictHostKeyChecking=no ubuntu@xxx.xxx.xxx.xxx
          cd ~/circleci-aws
          git pull
          npm i
          npm run build
          pm2 restart build/server

最佳答案

这是一个旧的,但它有很多观点,所以我发现的东西似乎值得分享。

在 CircleCI 文档 ( https://circleci.com/docs/2.0/configuration-reference/#shorthand-syntax ) 中,他们指出在使用 run 速记语法时,您还可以执行多行。

看起来像下面这样

- run: |
    git add --all
    git commit -am "a commit message"
    git push

问题示例与此示例之间的区别在于命令在“运行”下,而不是“命令”下。

关于unix - CircleCI 运行多行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51672067/

相关文章:

c - 删除 root 权限

python-3.x - 在作业 Circle Ci 中使用 Blackbox 时出现错误 "gpg: decryption failed: No secret key"

使用 Circleci config.yml 进行 Azure 应用服务插槽和交换部署

linux - 通过 ssh 运行带有多行输入的 bash 命令

node.js - 如何在 dredd.yml 文件中为 dredd 测试设置环境变量?

linux - Linux 终端中是否有用于按键的预输入缓冲区?

linux - $(()) 和 expr 有什么区别?

linux - 比较两个文件并在第二个文件中没有值时添加零

linux - 如何在不停止其他shell脚本执行的情况下监控后台运行的进程

c - 在 execl() bash 返回 eio(输入/输出错误)后从标准输入读取