Commit d300ecf8 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Allow to pass name of created artifacts archive in `.gitlab-ci.yml`

parent ad4d3a07
...@@ -18,6 +18,7 @@ v 8.6.0 (unreleased) ...@@ -18,6 +18,7 @@ v 8.6.0 (unreleased)
- Rewrite logo to simplify SVG code (Sean Lang) - Rewrite logo to simplify SVG code (Sean Lang)
- Allow to use YAML anchors when parsing the `.gitlab-ci.yml` (Pascal Bach) - Allow to use YAML anchors when parsing the `.gitlab-ci.yml` (Pascal Bach)
- Ignore jobs that start with `.` (hidden jobs) - Ignore jobs that start with `.` (hidden jobs)
- Allow to pass name of created artifacts archive in `.gitlab-ci.yml`
- Add support for cross-project label references - Add support for cross-project label references
- Update documentation to reflect Guest role not being enforced on internal projects - Update documentation to reflect Guest role not being enforced on internal projects
- Allow search for logged out users - Allow search for logged out users
......
...@@ -453,6 +453,67 @@ release-job: ...@@ -453,6 +453,67 @@ release-job:
The artifacts will be sent to GitLab after a successful build and will The artifacts will be sent to GitLab after a successful build and will
be available for download in the GitLab UI. be available for download in the GitLab UI.
#### artifacts:name
_**Note:** Introduced in GitLab 8.6 and GitLab Runner v1.1.0._
The `name` directive allows you to define the name of created artifacts archive.
Currently the `artifacts` is used.
It may be useful when you will want to download the archive from GitLab.
You could possible have the unique name of every archive.
The `artifacts:name` variable can use any of the [predefined variables](../variables/README.md).
---
**Example configurations**
To create a archive with a name of current build:
```yaml
job:
artifacts:
name: "$CI_BUILD_NAME"
```
To create a archive with a name of current branch or tag:
```yaml
job:
artifacts:
name: "$CI_BUILD_REF_NAME"
untracked: true
```
To create a archive with a name of current branch or tag:
```yaml
job:
artifacts:
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
untracked: true
```
To create a archive with a name of stage and branch name:
```yaml
job:
artifacts:
name: "${CI_BUILD_STAGE}_${CI_BUILD_REF_NAME}"
untracked: true
```
If you use **Windows Batch** to run your shell scripts you need to replace
`$` with `%`:
```yaml
job:
artifacts:
name: "%CI_BUILD_STAGE%_%CI_BUILD_REF_NAME%"
untracked: true
```
### cache ### cache
_**Note:** Introduced in GitLab Runner v0.7.0._ _**Note:** Introduced in GitLab Runner v0.7.0._
......
...@@ -218,6 +218,10 @@ module Ci ...@@ -218,6 +218,10 @@ module Ci
end end
def validate_job_artifacts!(name, job) def validate_job_artifacts!(name, job)
if job[:artifacts][:name] && !validate_string(job[:artifacts][:name])
raise ValidationError, "#{name} job: artifacts:name parameter should be a string"
end
if job[:artifacts][:untracked] && !validate_boolean(job[:artifacts][:untracked]) if job[:artifacts][:untracked] && !validate_boolean(job[:artifacts][:untracked])
raise ValidationError, "#{name} job: artifacts:untracked parameter should be an boolean" raise ValidationError, "#{name} job: artifacts:untracked parameter should be an boolean"
end end
......
...@@ -397,7 +397,7 @@ module Ci ...@@ -397,7 +397,7 @@ module Ci
services: ["mysql"], services: ["mysql"],
before_script: ["pwd"], before_script: ["pwd"],
rspec: { rspec: {
artifacts: { paths: ["logs/", "binaries/"], untracked: true }, artifacts: { paths: ["logs/", "binaries/"], untracked: true, name: "custom_name" },
script: "rspec" script: "rspec"
} }
}) })
...@@ -417,6 +417,7 @@ module Ci ...@@ -417,6 +417,7 @@ module Ci
image: "ruby:2.1", image: "ruby:2.1",
services: ["mysql"], services: ["mysql"],
artifacts: { artifacts: {
name: "custom_name",
paths: ["logs/", "binaries/"], paths: ["logs/", "binaries/"],
untracked: true untracked: true
} }
...@@ -619,6 +620,13 @@ module Ci ...@@ -619,6 +620,13 @@ 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:name is not an a string" do
config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { name: 1 } } })
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: artifacts:name parameter should be a string")
end
it "returns errors if job artifacts:untracked 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: { untracked: "string" } } }) config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { untracked: "string" } } })
expect do expect do
......
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