Skip to content

Commit

Permalink
Implement additional labels
Browse files Browse the repository at this point in the history
fixes #87
  • Loading branch information
samrocketman committed Oct 27, 2016
1 parent ef233c1 commit cfe0d7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,14 @@ env:
if(platform_obj) {
labels = [this.label_stability, this.label_platform, this.label_os, this.label_sudo, labels].join('&&')
}
//build on additional labels
def additional_labels = getObjectValue(jervis_yaml, 'jenkins.additional_labels', new Object())
if(additional_labels instanceof String) {
labels += "&&${additional_labels}"
}
else if(additional_labels instanceof List) {
labels += "&&" + additional_labels.findAll { it instanceof String }.join('&&')
}
return labels
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,14 @@ class lifecycleGeneratorTest extends GroovyTestCase {
generator.loadYamlString(yaml)
assert 'stable&&docker&&ubuntu1404&&sudo&&language:ruby&&gemfile&&env&&rvm&&jdk'.equals(generator.getLabels())
}
@Test public void test_lifecycleGenerator_getLabels_additional_labels() {
String yaml = 'language: ruby\njenkins:\n additional_labels: foo'
generator.loadYamlString(yaml)
assert 'language:ruby&&gemfile&&env&&rvm&&jdk&&foo'.equals(generator.getLabels())
yaml = 'language: ruby\njenkins:\n additional_labels:\n - foo\n - bar'
generator.loadYamlString(yaml)
assert 'language:ruby&&gemfile&&env&&rvm&&jdk&&foo&&bar'.equals(generator.getLabels())
}
@Test public void test_lifecycleGenerator_isRestricted() {
String yaml = 'language: ruby'
URL url = this.getClass().getResource('/good_platforms_simple.json');
Expand Down

0 comments on commit cfe0d7b

Please # to comment.