要确保不同git分支的Travis CI具有不同的工作流,可以通过以下步骤实现:
示例:
假设有一个代码仓库,其中包含两个分支:master和develop。现在我们想要确保这两个分支在Travis CI中具有不同的工作流程。
# master分支的工作流
jobs:
include:
- stage: build
script: echo "Building on master branch"
- stage: test
script: echo "Testing on master branch"
# develop分支的工作流
branches:
only:
- develop
jobs:
include:
- stage: build
script: echo "Building on develop branch"
- stage: test
script: echo "Testing on develop branch"
# 创建并切换到develop分支
$ git checkout -b develop
# 创建并切换到master分支
$ git checkout -b master
这样,当在master分支进行代码提交或Pull Request时,Travis CI将触发master分支的工作流;而在develop分支进行代码提交时,Travis CI将触发develop分支的工作流。
领取专属 10元无门槛券
手把手带您无忧上云