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 support for jenkins-cli's update-job command #17

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 6 additions & 4 deletions providers/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def new_job_url

def job_exists
url = URI.parse(job_url)
res = Chef::REST::RESTRequest.new(:GET, url, nil).call
res = Chef::REST::RESTRequest.new(:GET, url, {}).call
Chef::Log.debug("[jenkins_job] GET #{url.request_uri} == #{res.code}")
res.kind_of?(Net::HTTPSuccess)
end
Expand All @@ -50,16 +50,18 @@ def post_job(url)

def action_create
unless job_exists
Chef::Log.debug("[jenkins_job] running create-job for #{@new_resource}")
jenkins_cli "create-job #{@new_resource.job_name} < #{@new_resource.config}"
end
end

#there is no cli update-job command
def action_update
if job_exists
post_job(job_url)
Chef::Log.debug("[jenkins_job] running update-job for #{@new_resource}")
jenkins_cli "update-job #{@new_resource.job_name} < #{@new_resource.config}"
else
post_job(new_job_url)
Chef::Log.debug("[jenkins_job] job does not exist. running create-job for #{@new_resource}")
jenkins_cli "create-job #{@new_resource.job_name} < #{@new_resource.config}"
end
end

Expand Down