Commit 97f58bae authored by Kamil Trzcinski's avatar Kamil Trzcinski

Change artifacts syntax to allow uploading untracked files

parent d0e3e823
...@@ -262,13 +262,28 @@ The above script will: ...@@ -262,13 +262,28 @@ The above script will:
### artifacts ### artifacts
`artifacts` is used to specify list of files and directories which should be attached to build after success. `artifacts` is used to specify list of files and directories which should be attached to build after success.
1. Send all files in `binaries` and `.config`:
``` ```
artifacts: artifacts:
- binaries/ paths:
- .config - binaries/
- .config
```
2. Send all git untracked files:
```
artifacts:
untracked: true
```
3. Send all git untracked files and files in `binaries`:
```
artifacts:
untracked: true
paths:
- binaries/
``` ```
The above definition will archive all files in `binaries/` and `.config`.
The artifacts will be send after the build success to GitLab and will be accessible in GitLab interface to download. The artifacts will be send after the build success to GitLab and will be accessible in GitLab interface to download.
This feature requires GitLab Runner v 0.7.0. This feature requires GitLab Runner v 0.7.0.
......
...@@ -160,11 +160,17 @@ module Ci ...@@ -160,11 +160,17 @@ module Ci
raise ValidationError, "#{name} job: except parameter should be an array of strings" raise ValidationError, "#{name} job: except parameter should be an array of strings"
end end
if job[:artifacts] && !validate_array_of_strings(job[:artifacts]) if job[:artifacts]
raise ValidationError, "#{name}: artifacts parameter should be an array of strings" if job[:artifacts][:untracked] && !validate_boolean(job[:artifacts][:untracked])
raise ValidationError, "#{name} job: artifacts:untracked parameter should be an boolean"
end end
if job[:allow_failure] && !job[:allow_failure].in?([true, false]) if job[:artifacts][:paths] && !validate_array_of_strings(job[:artifacts][:paths])
raise ValidationError, "#{name} job: artifacts:paths parameter should be an array of strings"
end
end
if job[:allow_failure] && !validate_boolean(job[:allow_failure])
raise ValidationError, "#{name} job: allow_failure parameter should be an boolean" raise ValidationError, "#{name} job: allow_failure parameter should be an boolean"
end end
...@@ -187,6 +193,10 @@ module Ci ...@@ -187,6 +193,10 @@ module Ci
value.is_a?(String) || value.is_a?(Symbol) value.is_a?(String) || value.is_a?(Symbol)
end end
def validate_boolean(value)
value.in?([true, false])
end
def process?(only_params, except_params, ref, tag) def process?(only_params, except_params, ref, tag)
if only_params.present? if only_params.present?
return false unless matching?(only_params, ref, tag) return false unless matching?(only_params, ref, tag)
......
...@@ -339,7 +339,10 @@ module Ci ...@@ -339,7 +339,10 @@ module Ci
image: "ruby:2.1", image: "ruby:2.1",
services: ["mysql"], services: ["mysql"],
before_script: ["pwd"], before_script: ["pwd"],
rspec: { artifacts: ["logs/", "binaries/"], script: "rspec" } rspec: {
artifacts: { paths: ["logs/", "binaries/"], untracked: true },
script: "rspec"
}
}) })
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
...@@ -356,7 +359,10 @@ module Ci ...@@ -356,7 +359,10 @@ module Ci
options: { options: {
image: "ruby:2.1", image: "ruby:2.1",
services: ["mysql"], services: ["mysql"],
artifacts: ["logs/", "binaries/"] artifacts: {
paths: ["logs/", "binaries/"],
untracked: true
}
}, },
when: "on_success", when: "on_success",
allow_failure: false allow_failure: false
...@@ -523,11 +529,18 @@ module Ci ...@@ -523,11 +529,18 @@ module Ci
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: when parameter should be on_success, on_failure or always") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: when parameter should be on_success, on_failure or always")
end end
it "returns errors if job artifacts is not an array of strings" do it "returns errors if job artifacts:untracked is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: "string" } }) config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { untracked: "string" } } })
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: artifacts:untracked parameter should be an boolean")
end
it "returns errors if job artifacts:paths is not an array of strings" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { paths: "string" } } })
expect do expect do
GitlabCiYamlProcessor.new(config) GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: artifacts parameter should be an array of strings") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: artifacts:paths parameter should be an array of strings")
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment