Merge pull request #929 from MikeMcQuaid/test-bot-jenkinsfile

test-bot: handle more Jenkins configurations.
This commit is contained in:
Mike McQuaid 2016-09-12 08:09:39 +01:00 committed by GitHub
commit 53c3123b53

View File

@ -881,11 +881,12 @@ module Homebrew
job = ENV["UPSTREAM_JOB_NAME"] job = ENV["UPSTREAM_JOB_NAME"]
id = ENV["UPSTREAM_BUILD_ID"] id = ENV["UPSTREAM_BUILD_ID"]
raise "Missing Jenkins variables!" if !jenkins || !job || !id raise "Missing Jenkins variables!" if !jenkins || !job || !id
bottles = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"] bottles = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"]
return if bottles.empty? return if bottles.empty?
end
FileUtils.cp bottles, Dir.pwd, :verbose => true FileUtils.cp bottles, Dir.pwd, :verbose => true
end
json_files = Dir.glob("*.bottle.json") json_files = Dir.glob("*.bottle.json")
bottles_hash = json_files.reduce({}) do |hash, json_file| bottles_hash = json_files.reduce({}) do |hash, json_file|
@ -900,29 +901,34 @@ module Homebrew
ENV["GIT_WORK_TREE"] = tap.path ENV["GIT_WORK_TREE"] = tap.path
ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git" ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git"
pr = ENV["UPSTREAM_PULL_REQUEST"]
number = ENV["UPSTREAM_BUILD_NUMBER"]
quiet_system "git", "am", "--abort" quiet_system "git", "am", "--abort"
quiet_system "git", "rebase", "--abort" quiet_system "git", "rebase", "--abort"
safe_system "git", "checkout", "-f", "master" safe_system "git", "checkout", "-f", "master"
safe_system "git", "reset", "--hard", "origin/master" safe_system "git", "reset", "--hard", "origin/master"
safe_system "brew", "update" safe_system "brew", "update"
if pr if (pr = ENV["UPSTREAM_PULL_REQUEST"])
pull_pr = "https://github.com/#{tap.user}/homebrew-#{tap.repo}/pull/#{pr}" pull_pr = "https://github.com/#{tap.user}/homebrew-#{tap.repo}/pull/#{pr}"
safe_system "brew", "pull", "--clean", pull_pr safe_system "brew", "pull", "--clean", pull_pr
end end
if ENV["UPSTREAM_BOTTLE_KEEP_OLD"] if ENV["UPSTREAM_BOTTLE_KEEP_OLD"] || ENV["BOT_PARAMS"].include?("--keep-old")
system "brew", "bottle", "--merge", "--write", "--keep-old", *json_files system "brew", "bottle", "--merge", "--write", "--keep-old", *json_files
else else
system "brew", "bottle", "--merge", "--write", *json_files system "brew", "bottle", "--merge", "--write", *json_files
end end
remote = "git@github.com:BrewTestBot/homebrew-#{tap.repo}.git" remote = "git@github.com:BrewTestBot/homebrew-#{tap.repo}.git"
git_tag = pr ? "pr-#{pr}" : "testing-#{number}" git_tag = if pr
"pr-#{pr}"
elsif (upstream_number = ENV["UPSTREAM_BUILD_NUMBER"])
"testing-#{upstream_number}"
elsif (number = ENV["BUILD_NUMBER"])
"other-#{number}"
end
if git_tag
safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{git_tag}" safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{git_tag}"
end
formula_packaged = {} formula_packaged = {}
@ -967,9 +973,11 @@ module Homebrew
end end
end end
if git_tag
safe_system "git", "tag", "--force", git_tag safe_system "git", "tag", "--force", git_tag
safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}" safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}"
end end
end
def sanitize_argv_and_env def sanitize_argv_and_env
if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup") if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup")