如何只在 master 分支上执行作业,或者如果在 master 分支上创建了标签?
如果之前所有作业都成功,我希望在 master 分支上的每种情况下最后执行 trigger_job。
publish_dev:
# should only run on master branch
only:
- master
publish_prd:
# should only run if a tag has been created on the master branch
only:
- tags:
except:
- branches
triger_job:
# should always run on the master branch
only:
- master
needs:
- job: publish_dev
- job: publish_prd
目前我从 CI-Job 收到以下错误消息,当在 master 分支上没有创建标签时。
'trigger_job' job needs 'publish_prd' job but it was not added to the pipeline
如果我在 trigger_job 中没有“needs”部分,则作业在完成 publish_dev 或 publish_prd 作业之前开始。
答案 0 :(得分:0)
publish_prd:
# should only run if a tag has been created on the master branch
only:
- tags:
except:
- branches
triger_job:
# should always run on the master branch
only:
- master
needs:
- job: publish_dev
- job: publish_prd
我们看到trigger_job需要jobpublish_prd和_dev,并且只在master上运行,而publish_prd只在tags上运行,所以trigger job在master上找不到。因此,为避免冲突,只需为标签添加另一个 tigger 作业即可。