Change artifacts syntax to allow uploading untracked files
This commit is contained in:
parent
d0e3e823a2
commit
97f58bae87
|
@ -262,13 +262,28 @@ The above script will:
|
|||
### artifacts
|
||||
`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:
|
||||
- binaries/
|
||||
- .config
|
||||
paths:
|
||||
- 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.
|
||||
|
||||
This feature requires GitLab Runner v 0.7.0.
|
||||
|
|
|
@ -160,11 +160,17 @@ module Ci
|
|||
raise ValidationError, "#{name} job: except parameter should be an array of strings"
|
||||
end
|
||||
|
||||
if job[:artifacts] && !validate_array_of_strings(job[:artifacts])
|
||||
raise ValidationError, "#{name}: artifacts parameter should be an array of strings"
|
||||
if job[:artifacts]
|
||||
if job[:artifacts][:untracked] && !validate_boolean(job[:artifacts][:untracked])
|
||||
raise ValidationError, "#{name} job: artifacts:untracked parameter should be an boolean"
|
||||
end
|
||||
|
||||
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] && !job[:allow_failure].in?([true, false])
|
||||
if job[:allow_failure] && !validate_boolean(job[:allow_failure])
|
||||
raise ValidationError, "#{name} job: allow_failure parameter should be an boolean"
|
||||
end
|
||||
|
||||
|
@ -187,6 +193,10 @@ module Ci
|
|||
value.is_a?(String) || value.is_a?(Symbol)
|
||||
end
|
||||
|
||||
def validate_boolean(value)
|
||||
value.in?([true, false])
|
||||
end
|
||||
|
||||
def process?(only_params, except_params, ref, tag)
|
||||
if only_params.present?
|
||||
return false unless matching?(only_params, ref, tag)
|
||||
|
|
|
@ -339,7 +339,10 @@ module Ci
|
|||
image: "ruby:2.1",
|
||||
services: ["mysql"],
|
||||
before_script: ["pwd"],
|
||||
rspec: { artifacts: ["logs/", "binaries/"], script: "rspec" }
|
||||
rspec: {
|
||||
artifacts: { paths: ["logs/", "binaries/"], untracked: true },
|
||||
script: "rspec"
|
||||
}
|
||||
})
|
||||
|
||||
config_processor = GitlabCiYamlProcessor.new(config)
|
||||
|
@ -356,7 +359,10 @@ module Ci
|
|||
options: {
|
||||
image: "ruby:2.1",
|
||||
services: ["mysql"],
|
||||
artifacts: ["logs/", "binaries/"]
|
||||
artifacts: {
|
||||
paths: ["logs/", "binaries/"],
|
||||
untracked: true
|
||||
}
|
||||
},
|
||||
when: "on_success",
|
||||
allow_failure: false
|
||||
|
@ -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
|
||||
|
||||
it "returns errors if job artifacts is not an array of strings" do
|
||||
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: "string" } })
|
||||
it "returns errors if job artifacts:untracked is not an array of strings" do
|
||||
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 parameter should be an array of strings")
|
||||
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
|
||||
GitlabCiYamlProcessor.new(config)
|
||||
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: artifacts:paths parameter should be an array of strings")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue