提交合并后在 git ci/cd 上触发脚本

Trigger scripts on git ci/cd after merge committed

我想从 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,并且在提交请求后部署我的 master 分支。 我只想执行我的 script2 代码中描述的脚本而不进行任何部署。

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

这是我使用的最终代码:

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