Skip to content

Commit dd6e237

Browse files
author
sanfrancrisko
authored
Merge pull request puppetlabs#436 from skoef/customBeforeSteps
added more fine-grained control of custom_before_steps
2 parents acfb1f4 + ed298c7 commit dd6e237

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
@@ -86,7 +86,7 @@ Gitlab CI uses a .gitlab-ci.yml file in the root of your repository tell Gitlab
8686
| 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.|
8787
| rubygems_mirror | Use a custom rubygems mirror url |
8888
| 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.|
89-
| 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.|
89+
| 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.|
9090
| 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`.|
9191
|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.|
9292
|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
@@ -56,8 +56,13 @@ default:
5656
<% if !configs.has_key?('default_before_script') || configs['default_before_script'] -%>
5757
before_script: &before_script
5858
<% if configs['custom_before_steps'] -%>
59-
<% configs['custom_before_steps'].each do |step| -%>
59+
<% if configs['custom_before_steps'].is_a? Array -%>
60+
<% configs['custom_before_steps'] = { 'before' => configs['custom_before_steps'] } -%>
61+
<% end -%>
62+
<% if configs['custom_before_steps']['before'] -%>
63+
<% configs['custom_before_steps']['before'].each do |step| -%>
6064
- <%= step %>
65+
<% end -%>
6166
<% end -%>
6267
<% end -%>
6368
- bundle -v
@@ -74,6 +79,11 @@ default:
7479
- gem --version
7580
- bundle -v
7681
- bundle install <%= configs['bundler_args'] %>
82+
<% if configs['custom_before_steps'] and configs['custom_before_steps']['after'] -%>
83+
<% configs['custom_before_steps']['after'].each do |step| -%>
84+
- <%= step %>
85+
<% end -%>
86+
<% end -%>
7787
<% end -%>
7888

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

0 commit comments

Comments
 (0)