gpt4 book ai didi

git - 是否可以在 gitlab-ci 中将另一个分支构建到另一个目录?

转载 作者:太空狗 更新时间:2023-10-29 13:10:49 28 4
gpt4 key购买 nike

我想使用一个 gitlab-runner 来构建两个相似但不完全相同的构建。

git 存储库中,我有几个分支:prod、test、dev。是否可以只使用一个运行者在不同的路径上 build ?

例如:

  • /home/gitlab-runner/builds/860ee11a/0/projectname - 产品
  • /home/gitlab-runner/builds/860ee11a/1/projectname - 测试
  • /home/gitlab-runner/builds/860ee11a/2/projectname - 开发

如果是这样,你是怎么做到的?

最佳答案

是的,你可以做到。

你可以使用这个逻辑:

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 另一个作业成功或失败时运行作业。

例子:

文档:

  • GitLab CI (工作、阶段、工件、唯一和除外等)

希望对您有所帮助!

关于git - 是否可以在 gitlab-ci 中将另一个分支构建到另一个目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35915170/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com