Skip to content

Commit ed298c7

Browse files
skoefReinier Schoof
authored andcommitted
added more fine-grained control of custom_before_steps
1 parent e97c50f commit ed298c7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Gitlab CI uses a .gitlab-ci.yml file in the root of your repository tell Gitlab
8585
| custom_jobs |Define custom Gitlab CI jobs that will be executed. It is recommended that you use this option if you need customized Gitlab CI jobs. Please see the [.gitlab-ci.yml](https://docs.gitlab.com/ce/ci/yaml/README.html) docs for specifics.|
8686
| rubygems_mirror | Use a custom rubygems mirror url |
8787
| image |Define the Docker image to use, when using the Docker runner. Please see the [Using Docker images](https://docs.gitlab.com/ee/ci/docker/using_docker_images.html) docs for specifics.|
88-
| custom_before_steps |Allows you to pass additional steps to the GitLab CI before_script. Please see the [.gitlab-ci.yml](https://docs.gitlab.com/ce/ci/yaml/#before_script-and-after_script) docs for specifics.|
88+
| custom_before_steps |Allows you to pass additional steps to the GitLab CI before_script. Please see the [.gitlab-ci.yml](https://docs.gitlab.com/ce/ci/yaml/#before_script-and-after_script) docs for specifics. If given as an array, the steps are executed _before_ the default steps of the before_script. If you want to have more control over the execution order of the steps, you can define a hash with a `before` and/or `after` key holding an array of steps to be executed before and after the default_script respectively.|
8989
| default_before_script |If false, removes the default `before_script` section. Useful if you need a customised Bundler install, or to remove Bundler entirely. If the key is unset the default behaviour is to add `before_script`.|
9090
|use_litmus| By default it is disabled. Set to `true` to configure travis to use Litmus testing tool for acceptance testing jobs with default values.|
9191
|litmus|Allows you to update default config values. Its sub keys are `provision_list`, `puppet_collection`, `ruby_version`, `install_wget` which are detailed below.|

moduleroot/.gitlab-ci.yml.erb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ default:
5050
<% if !configs.has_key?('default_before_script') || configs['default_before_script'] -%>
5151
before_script: &before_script
5252
<% if configs['custom_before_steps'] -%>
53-
<% configs['custom_before_steps'].each do |step| -%>
53+
<% if configs['custom_before_steps'].is_a? Array -%>
54+
<% configs['custom_before_steps'] = { 'before' => configs['custom_before_steps'] } -%>
55+
<% end -%>
56+
<% if configs['custom_before_steps']['before'] -%>
57+
<% configs['custom_before_steps']['before'].each do |step| -%>
5458
- <%= step %>
59+
<% end -%>
5560
<% end -%>
5661
<% end -%>
5762
- bundle -v
@@ -68,6 +73,11 @@ default:
6873
- gem --version
6974
- bundle -v
7075
- bundle install <%= configs['bundler_args'] %>
76+
<% if configs['custom_before_steps'] and configs['custom_before_steps']['after'] -%>
77+
<% configs['custom_before_steps']['after'].each do |step| -%>
78+
- <%= step %>
79+
<% end -%>
80+
<% end -%>
7181
<% end -%>
7282

7383
<% if configs['ruby_versions'] -%>

0 commit comments

Comments
 (0)