Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to delete a promotion configuration #176

Merged
merged 1 commit into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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