是的,你可以这么做。
您可以使用以下逻辑:
image: <image> # choose your image (ryby, python, node, php etc)
# add cache for speeding up builds
cache:
paths:
- <cache-folder>/ # the name will need to be set according to your project
before_script:
- <your command> # here you set the commands you want to run for every commit
- <your command>
# add a job called 'build' -> to run your builds
build:
stage: build # this will define the stage
script:
- <your scripts> # choose the script you want to run first
only:
- build # the 'build' job will affect only 'build' branch
# add a job called 'test' -> to run your tests
test:
stage: test # this will define the stage
script:
- <your scripts> # choose the script similar to the deployment
except:
- master # the 'test' job will affect all branches expect 'master'
# the 'deploy' job will deploy and build your project
deploy:
stage: deploy
script:
- <your scripts> # your deployment script
artifacts:
paths:
- <folder> # generate files resulting from your builds for you to download
only:
- master # this job will affect only the 'master' branch
您还可以使用另一个成功或失败 when
来运行作业。when
例子:
文件:
希望有所帮助!