diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-15 15:54:35 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-15 15:54:35 +0000 |
commit | c19795dff596a6a7343460a36f4a430c3bf0eb03 (patch) | |
tree | 1d87b4373a7fe9151ab656c2ab32a0bf1d842168 /lib | |
parent | 57d8faf662930ef0941b364f7b4e2fa1b60a8cf1 (diff) | |
parent | 1ce766367eb529fe88068be2f34315f87d74a349 (diff) | |
download | gitlab-ce-c19795dff596a6a7343460a36f4a430c3bf0eb03.tar.gz |
Merge branch 'ci/build_dependencies' into 'master'
Let the CI runner know about builds that this build depends on
This allows us to implement artifacts passing: runner will download artifacts from all prior builds. It will happen automatically, and always, as long as artifacts are enabled.
## The changes:
This MR exposes list of prior builds in CI::API::Builds.
**The API response when asking for builds**
```json
{
"id": 48584,
"ref": "0.1.1",
"tag": true,
"sha": "d63117656af6ff57d99e50cc270f854691f335ad",
"status": "success",
"name": "pages",
"token": "9dd60b4f1a439d1765357446c1084c",
"stage": "test",
"project_id": 479,
"project_name": "test",
"commands": "echo commands",
"repo_url": "http://gitlab-ci-token:token@gitlab.example/group/test.git",
"before_sha": "0000000000000000000000000000000000000000",
"allow_git_fetch": false,
"options": {
"image": "docker:image",
"artifacts": {
"paths": [
"public"
]
},
"cache": {
"paths": [
"vendor"
]
}
},
"timeout": 3600,
"variables": [
{
"key": "CI_BUILD_TAG",
"value": "0.1.1",
"public": true
}
],
"dependencies": {
"builds": [
{
"id": 48584,
"ref": "0.1.1",
"tag": true,
"sha": "d63117656af6ff57d99e50cc270f854691f335ad",
"status": "success",
"name": "build",
"token": "9dd60b4f1a439d1765357446c1084c",
"stage": "build",
"project_id": 479,
"project_name": "test",
"artifacts_file": {
"filename": "artifacts.zip",
"size": 0
}
}
]
}
}
```
## How it will work?
**Example:**
```
build:
type: build
script:
- echo TEST > test_file
artifacts:
untracked: true
rspec:
type: test
script:
- test-my-project
staging:
type: deploy
script:
- scp test_file root@server.com:
```
**The flow:**
1. We run `build`. The `build` creates a file `test_file`. This file gets archived and send us build artifacts.
2. We run `rspec`. The `rspec` downloads build artifacts from `build`. Uses the `test_file`.
3. We run `staging`. The `staging` downloads build artifacts from `build` and `rspec`, but since the `rspec` doesn't have build artifacts we skip that build. Deploys the `test_file`.
This partially implements the https://gitlab.com/gitlab-org/gitlab-ce/issues/3423.
In the next release we will introduce option to configure what artifacts are received.
/cc @grzesiek @DouweM @sytse @rspeicher
See merge request !2437
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/api/builds.rb | 4 | ||||
-rw-r--r-- | lib/ci/api/entities.rb | 17 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index fb87637b94f..690bbf97a89 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -20,7 +20,7 @@ module Ci if build update_runner_info - present build, with: Entities::Build + present build, with: Entities::BuildDetails else not_found! end @@ -111,7 +111,7 @@ module Ci build.artifacts_metadata = metadata if build.save - present(build, with: Entities::Build) + present(build, with: Entities::BuildDetails) else render_validation_error!(build) end diff --git a/lib/ci/api/entities.rb b/lib/ci/api/entities.rb index e4ac0545ea2..b25e0e573a8 100644 --- a/lib/ci/api/entities.rb +++ b/lib/ci/api/entities.rb @@ -16,10 +16,19 @@ module Ci end class Build < Grape::Entity - expose :id, :commands, :ref, :sha, :status, :project_id, :repo_url, - :before_sha, :allow_git_fetch, :project_name - + expose :id, :ref, :tag, :sha, :status expose :name, :token, :stage + expose :project_id + expose :project_name + expose :artifacts_file, using: ArtifactFile, if: lambda { |build, opts| build.artifacts? } + end + + class BuildDetails < Build + expose :commands + expose :repo_url + expose :before_sha + expose :allow_git_fetch + expose :token expose :options do |model| model.options @@ -30,7 +39,7 @@ module Ci end expose :variables - expose :artifacts_file, using: ArtifactFile + expose :depends_on_builds, using: Build end class Runner < Grape::Entity |