gitlab - 如何在 MR 上运行 GitLab CI 构建?

标签 gitlab

我是 GitLab CI 的新手,尝试设置一个在创建合并请求时需要触发的构建。目前,构建在 MR 被接受并合并到“开发”分支后运行。这很好。但我也期望在创建 MR 时构建能够运行。

我的 gitlab-ci.yml 如下 - 我错过了什么吗?

stages:
  - test

test_project:
  stage: test
  script:
    - xcodebuild -scheme CodeRedTests -sdk iphonesimulator10.2 -workspace CodeRed.xcworkspace -configuration Debug clean build test -destination "platform=iOS Simulator,OS=10.2,name=iPhone 5s" | xcpretty -s
  only:
    - develop
  tags:
    - ios_10
    - xcode_8
    - osx_10-12

最佳答案

创建 MR 时运行测试已 hot topic从2015年开始,甚至更久。 准确地说,需要在某个管道中对合并的代码(从您的分支到开发)运行测试。如果一切正常,那么 MR 就会亮绿灯。

目前不可用。一个doc说:

In old workflows the Continuous Integration (CI) server commonly ran tests on the master branch only. Developers had to ensure their code did not break the master branch. When using GitLab flow developers create their branches from this master branch so it is essential it is green. Therefore each merge request must be tested before it is accepted. CI software like Travis and GitLab CI show the build results right in the merge request itself to make this easy. One drawback is that they are testing the feature branch itself and not the merged result. What one can do to improve this is to test the merged result itself. The problem is that the merge result changes every time something is merged into master. Retesting on every commit to master is computationally expensive and means you are more frequently waiting for test results. If there are no merge conflicts and the feature branches are short lived the risk is acceptable. If there are merge conflicts you merge the master branch into the feature branch and the CI server will rerun the tests. If you have long lived feature branches that last for more than a few days you should make your issues smaller.

因此,您可以尝试将开发合并到功能分支以确保一切正常,但您必须删除 only:develop 限制。

关于gitlab - 如何在 MR 上运行 GitLab CI 构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41674762/

相关文章:

docker - 为什么我的 Arquillian Drone 功能测试不能在 GitLab CI 上运行?

当合并请求被合并时,Gitlab 运行管道作业

continuous-integration - Gitlab CI 不执行 npm 脚本

docker - Gitlab-runner 本地构建 - 从非 TTY 设备登录

kubernetes - 如何 kubectl 端口转发 GitLab web 服务?

docker - 在 Gitlab 运行器中的 Docker 容器内运行测试命令时出现问题

java - Gradle jacoco 多项目。如何在终端输出所有项目的代码覆盖率?

docker - subgit超时等待pid文件

git - 查找目录下所有一级子目录的事件 git 分支

ruby - 集成 Gitlab 和 TravisCi