summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-11-09 12:18:00 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2015-11-10 12:51:50 +0100
commit97f58bae87dfcfb36d5a7a490b1c0983435a19f4 (patch)
tree6c4c8d2c35280c45d19f1e7f6d6bd769e05d5f41
parentd0e3e823a2dd56260550aec648b0cbfae64543ae (diff)
downloadgitlab-ce-97f58bae87dfcfb36d5a7a490b1c0983435a19f4.tar.gz
Change artifacts syntax to allow uploading untracked files
-rw-r--r--doc/ci/yaml/README.md21
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb16
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb23
3 files changed, 49 insertions, 11 deletions
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index d8504aca86a..11065fee012 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -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.
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 6f9af5388ca..2e2209031ee 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -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)
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index 5e3779af19e..29fc2713821 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -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