【问题标题】:Trigger scripts on git ci/cd after merge committed合并提交后在 git ci/cd 上触发脚本
【发布时间】:2019-07-25 07:39:36
【问题描述】:

我想从 git ci/cd 调用一些脚本。 第一个脚本应该在抛出合并请求时执行,然后在管理员提交请求后,我想执行另一个脚本

这是我现在在 .yml 上的代码:

script1:
  script: 
  - sshpass -p password ssh user@host "cmd.exe /c powershell.exe path\to\local\script1"  
  only:
  - merge_requests

script2:
  script: 
  - sshpass -p password ssh user@host "cmd.exe /c powershell.exe path\to\local\script2"  
  stage: deploy

使用这些代码,当合并请求被抛出时,git ci 仍然执行我的 script2,并在提交请求后部署我的主分支。 我只想执行我的 script2 代码中描述的脚本而不进行任何部署。

【问题讨论】:

    标签: git automation release git-merge


    【解决方案1】:

    最后我只在我的目标分支上使用。

    这是我使用的最终代码:

    script1:
      script: 
      - sshpass -p password ssh user@host "cmd.exe /c powershell.exe path\to\local\script1"  
      only:
      - merge_requests
    
    script2:
      script: 
      - sshpass -p password ssh user@host "cmd.exe /c powershell.exe path\to\local\script2"  
      only:
      - mytargetbranch
    

    【讨论】:

      猜你喜欢
      • 2021-11-05
      • 1970-01-01
      • 1970-01-01
      • 2018-11-29
      • 2012-03-22
      • 2017-10-29
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多