Skip to content

Commit

Permalink
Merge pull request #176 from practicefusion/feature/add-delete-promotion
Browse files Browse the repository at this point in the history
add ability to delete a promotion configuration
  • Loading branch information
arangamani committed Apr 22, 2015
2 parents 36e88f5 + 90a79a1 commit 688c0d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/jenkins_api_client/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def build_freestyle_config(params)
"#{params[:block_build_when_downstream_building]}")
xml.blockBuildWhenUpstreamBuilding(
"#{params[:block_build_when_upstream_building]}")
xml.triggers.vector do
xml.triggers.vector do
if params[:timer]
xml.send("hudson.triggers.TimerTrigger") do
xml.spec params[:timer]
Expand Down Expand Up @@ -360,7 +360,7 @@ def build_freestyle_config(params)
xml.buildWrappers
end
end

xml_doc = Nokogiri::XML(builder.to_xml)
plugin_collection.configure(xml_doc).to_xml
end
Expand Down Expand Up @@ -449,7 +449,7 @@ def add_skype_notification(params)
# @option artifact_params [Boolean] :default_excludes (false)
# exclude defaults automatically
#
# @return [Nokogiri::XML::Builder]
# @return [Nokogiri::XML::Builder]
#
def artifact_archiver(artifact_params, xml)
return xml if artifact_params.nil?
Expand Down Expand Up @@ -1518,6 +1518,16 @@ def set_promote_config(job_name, process, config)
@client.post_config("/job/#{job_name}/promotion/process/#{process}/config.xml", config)
end

# Delete a job's promotion config
#
# @param [String] job_name
# @param [String] process The process name
# @return nil
def delete_promote_config(job_name, process)
@logger.info "Deleting promote config for job '#{job_name}' process '#{process}'"
@client.post_config("/job/#{job_name}/promotion/process/#{process}/doDelete")
end

#A Method to find artifacts path from the Current Build
#
# @param [String] job_name
Expand Down
7 changes: 7 additions & 0 deletions spec/unit_tests/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,13 @@
end
end

describe "#delete_promote_config" do
it "accepts name and process and deletes promotion config" do
@client.should_receive(:post_config).with('/job/testjob/promotion/process/promo/doDelete')
@job.delete_promote_config('testjob', 'promo')
end
end

describe '#scm_git' do
before do
@job.send(:scm_git, {
Expand Down

0 comments on commit 688c0d4

Please sign in to comment.