首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否有可能在gitlab中构建另一个分支到另一个目录?

是否有可能在gitlab中构建另一个分支到另一个目录?
EN

Stack Overflow用户
提问于 2016-03-10 11:28:00
回答 2查看 10.3K关注 0票数 6

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

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

例如:

  • /home/gitlab-runner/builds/860ee11a/0/projectname - prod
  • /home/gitlab-runner/builds/860ee11a/1/projectname -试验
  • /home/gitlab-runner/builds/860ee11a/2/projectname - dev

如果是的话,你是如何做到的?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-11 04:10:27

是的,你能做到的。

您可以使用以下逻辑:

代码语言:javascript
复制
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 (其他作业成功或失败)。

示例:

医生:

  • GitLab CI (作业、阶段、工件、仅&除外等)

希望能帮上忙!

票数 5
EN

Stack Overflow用户

发布于 2016-03-10 12:26:23

是的,这是默认行为。每当你推到回购(不管分支),一个活跃的跑步者将继续运行您的构建。日志和工件是独立存储的。

在您的..gitlab ci.yml中,您可以根据分支或标记名采取不同的操作。有关更多信息,请参见http://doc.gitlab.com/ce/ci/yaml/README.html,并查找唯一和除关键字外的关键字。

最后,您可以创建使用API的触发器。请参阅http://doc.gitlab.com/ce/ci/triggers/README.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35915170

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档