forked from voxpupuli/puppet-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added jenkins_prefix function to retrieve configured prefix
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
module Puppet::Parser::Functions | ||
newfunction(:jenkins_prefix, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| | ||
Return the configured Jenkins prefix value | ||
(corresponds to /etc/defaults/jenkins -> PREFIX) | ||
Example: | ||
$prefix = jenkins_prefix() | ||
ENDHEREDOC | ||
|
||
config_hash = lookupvar('::jenkins::config_hash') | ||
if config_hash && \ | ||
config_hash['PREFIX'] && \ | ||
config_hash['PREFIX']['value'] | ||
return config_hash['PREFIX']['value'] | ||
else | ||
return lookupvar('::jenkins::params::prefix') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
# Skip this example block under puppet-4 as it will fail with rspec-puppet | ||
# 2.1.0. | ||
# | ||
# https://github.com/rodjek/rspec-puppet/issues/282 | ||
describe 'jenkins_prefix', :if => Puppet.version.to_f < 4.0 do | ||
|
||
let(:facts) { { :osfamily => 'RedHat', :operatingsystem => 'RedHat' } } | ||
let(:pre_condition) { 'include ::jenkins' } | ||
# Lazily loaded function call to be used in examples. Not overwriting | ||
# `subject` since rspec-puppet is already defining that to return the | ||
# function | ||
let(:prefix) { | ||
subject.call([]) | ||
} | ||
|
||
it 'should default to ""' do | ||
expect(prefix).to eql '' | ||
end | ||
|
||
context 'with overwritten configuration' do | ||
let(:pre_condition) do | ||
<<-ENDPUPPET | ||
class { 'jenkins': | ||
config_hash => {'PREFIX' => {'value' => '/test'}}, | ||
} | ||
ENDPUPPET | ||
end | ||
|
||
it 'should be our overwritten prefix' do | ||
expect(prefix).to eql('/test') | ||
end | ||
end | ||
end |