ext/packaging/tasks/jenkins.rake in puppet-2.7.22 vs ext/packaging/tasks/jenkins.rake in puppet-2.7.23
- old
+ new
@@ -89,22 +89,14 @@
# It expects a the following arguments
# 1. :build_task => The lower-level pl: or pe: task we're executing, e.g. pl:deb_all
#
task :post_build, :build_task do |t, args|
# Check for a dirty tree before allowing a remote build that is doomed to unexpected results
- if source_dirty?
- warn "The source tree is dirty, e.g. there are uncommited changes. Please commit/discard changes and try again."
- exit 1
- end
+ fail_on_dirty_source
# We use JSON for parsing the json part of the submission to JSON
- begin
- require 'json'
- rescue LoadError
- warn "Couldn't require 'json'. JSON is required for sanely generating the string we curl to Jenkins."
- exit 1
- end
+ require_library_or_fail 'json'
build_task = args.build_task
##
# We set @:task of @build manually with our task data so the remote
# build knows what to do. Puppetdb needs early knowledge of if this is
@@ -119,11 +111,10 @@
when /deb/ then "deb"
when /mock/ then "rpm"
when /dmg|apple/ then "dmg"
when /gem/ then "gem"
when /tar/ then "tar"
- when /sles/ then "sles"
else raise "Could not determine build type for #{build_task}"
end
#
# Create the data files to send to jenkins
properties = @build.params_to_yaml
@@ -170,20 +161,22 @@
job_url = "#{@build.jenkins_build_host}/job/#{@build.jenkins_packaging_job}"
trigger_url = "#{job_url}/build"
# Call out to the curl_form_data utility method in 00_utils.rake
#
- if curl_form_data(trigger_url, args)
- puts "Build submitted. To view your build results, go to #{job_url}"
- puts "Your packages will be available at #{@build.distribution_server}:#{@build.jenkins_repo_path}/#{@build.project}/#{@build.ref}"
- else
- warn "An error occurred submitting the job to jenkins. Take a look at the preceding http response for more info."
+ begin
+ if curl_form_data(trigger_url, args)
+ puts "Build submitted. To view your build results, go to #{job_url}"
+ puts "Your packages will be available at #{@build.distribution_server}:#{@build.jenkins_repo_path}/#{@build.project}/#{@build.ref}"
+ else
+ fail "An error occurred submitting the job to jenkins. Take a look at the preceding http response for more info."
+ end
+ ensure
+ # Clean up after ourselves
+ rm bundle
+ rm properties
end
-
- # Clean up after ourselves
- rm bundle
- rm properties
end
end
end
##
@@ -215,55 +208,39 @@
sleep 5
end
end
# This does the mocks in parallel
- desc "Queue pl:mock-all on jenkins builder"
+ desc "Queue pl:mock_all on jenkins builder"
task :mock_all => "pl:fetch" do
@build.final_mocks.split(' ').each do |mock|
@build.default_mock = mock
invoke_task("pl:jenkins:post_build", "pl:mock")
sleep 5
end
end
- desc "Jenkins UBER build: build all the things with jenkins"
- task :uber_build do
- uber_tasks = ["jenkins:deb_all", "jenkins:mock_all", "jenkins:tar"]
- uber_tasks << "jenkins:dmg" if @build.build_dmg
- uber_tasks << "jenkins:gem" if @build.build_gem
- uber_tasks.map { |t| "pl:#{t}" }.each do |t|
- invoke_task(t)
- sleep 5
- end
- end
-
desc "Retrieve packages built by jenkins, sign, and ship all!"
task :uber_ship => "pl:fetch" do
uber_tasks = ["jenkins:retrieve", "jenkins:sign_all", "uber_ship", "remote:freight", "remote:update_yum_repo" ]
uber_tasks.map { |t| "pl:#{t}" }.each { |t| Rake::Task[t].invoke }
Rake::Task["pl:jenkins:ship"].invoke("shipped")
end
end
end
##
-# If this is a PE project, we want PE tasks as well. However, because the
-# PE tasks use :remote as their default (e.g., not namespaced under remote)
-# we have to explicily use the "local" tasks, since these will be local
-# builds on jenkins agents. Also, we support building on SLES for PE, so we
-# add a sles task.
+# If this is a PE project, we want PE tasks as well.
#
if @build.build_pe
namespace :pe do
namespace :jenkins do
- tasks << "sles"
tasks.each do |build_task|
desc "Queue pe:#{build_task} build on jenkins builder"
task build_task => "pl:fetch" do
check_var("PE_VER", @build.pe_version)
- invoke_task("pl:jenkins:post_build", "pe:local_#{build_task}")
+ invoke_task("pl:jenkins:post_build", "pe:#{build_task}")
end
end
# While pl:remote:deb_all does all cows in serially, with jenkins we
# parallelize them. This breaks the cows up and posts a build for all of
@@ -272,34 +249,25 @@
desc "Queue pe:deb_all on jenkins builder"
task :deb_all => "pl:fetch" do
check_var("PE_VER", @build.pe_version)
@build.cows.split(' ').each do |cow|
@build.default_cow = cow
- invoke_task("pl:jenkins:post_build", "pe:local_deb")
+ invoke_task("pl:jenkins:post_build", "pe:deb")
sleep 5
end
end
# This does the mocks in parallel
- desc "Queue pe:mock-all on jenkins builder"
+ desc "Queue pe:mock_all on jenkins builder"
task :mock_all => "pl:fetch" do
@build.final_mocks.split(' ').each do |mock|
@build.default_mock = mock
- invoke_task("pl:jenkins:post_build", "pe:local_mock")
+ invoke_task("pl:jenkins:post_build", "pe:mock")
sleep 5
end
end
- desc "Queue builds of all PE packages for this project in Jenkins"
- task :uber_build => "pl:fetch" do
- check_var("PE_VER", @build.pe_version)
- ["tar", "deb_all", "mock_all", "sles"].each do |task|
- invoke_task("pe:jenkins:#{task}")
- sleep 5
- end
- end
-
desc "Retrieve PE packages built by jenkins, sign, and ship all!"
task :uber_ship => "pl:fetch" do
check_var("PE_VER", @build.pe_version)
["pl:jenkins:retrieve", "pl:jenkins:sign_all", "pe:ship_rpms", "pe:ship_debs"].each do |task|
Rake::Task[task].invoke
@@ -331,19 +299,17 @@
#
namespace :pl do
namespace :jenkins do
desc "Trigger a jenkins uri with SHA of HEAD as a string param, requires \"URI\""
task :post, :uri do |t, args|
- uri = args.uri || ENV['URI']
- raise "pl:jenkins:post requires a URI, either via URI= or pl:jenkin:post[URI]" if uri.nil?
+ uri = (args.uri or ENV['URI']) or fail "pl:jenkins:post requires a URI, either via URI= or pl:jenkin:post[URI]"
# We use JSON for parsing the json part of the submission.
begin
require 'json'
rescue LoadError
- warn "Couldn't require 'json'. JSON is required for sanely generating the string we curl to Jenkins."
- exit 1
+ fail "Couldn't require 'json'. JSON is required for sanely generating the string we curl to Jenkins."
end
# Assemble the JSON string for the JSON parameter
json = JSON.generate("parameter" => [{ "name" => "SHA", "value" => "#{@build.ref}" }])
@@ -355,10 +321,10 @@
]
if curl_form_data(uri, args)
puts "Job triggered at #{uri}."
else
- puts "An error occurred attempting to trigger the job at #{uri}. Please see the preceding http response for more info."
+ fail "An error occurred attempting to trigger the job at #{uri}. Please see the preceding http response for more info."
end
end
end
end