Skip to content

Commit

Permalink
handle special modules that do not have github repo in yast-{mod} for…
Browse files Browse the repository at this point in the history
…mat, fix sed for oneliner xml and improve error reporting
  • Loading branch information
jreidinger committed Mar 26, 2015
1 parent 7b0c53c commit 34c0b20
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions jenkins-tools/yast-jenkins-modify.rb
Expand Up @@ -17,17 +17,37 @@
URL_BASE = "https://#{USER}:#{PWD}@ci.opensuse.org"
#URL_BASE = "http://river.suse.de"

# modules that do not follow yast-{mod} convention
SPECIAL_MOD_NAMES = [
"skelcd-control-SLES",
"skelcd-control-SLED",
"skelcd-control-openSUSE",
"skelcd-control-openSUSE-LangAddOn",
"skelcd-control-SLES-for-VMware",
"y2r"
]

ARGV.each do |mod|
#test if module already exist
response_code = `curl -sL -w "%{http_code}" #{URL_BASE}/job/#{JOB_NAME_PATTERN % mod}/ -o /dev/null`
raise "module #{mod} do not exists" unless response_code == "200"

FileUtils.rm_f "config.xml.tmp"
git_name = SPECIAL_MOD_NAMES.include?(mod) ? mod : "yast-#{mod}"
# now modify config.xml to fit given module
`sed 's/yast-.*\.git/yast-#{mod}.git/' config.xml > config.xml.tmp`
`sed 's/yast-[a-z_-]*\.git/#{git_name}.git/' config.xml > config.xml.tmp`

# adress found from https://ci.opensuse.org/api
res = `curl -X POST #{URL_BASE}/job/#{JOB_NAME_PATTERN % mod}/config.xml --header "Content-Type:application/xml" -d @config.xml.tmp`
puts "ERROR: #{res}" if $?.exitstatus != 0
puts "ERROR: Wrong Credentials. \n #{res}" if res =~ /Authentication required/
cmd = "curl -X POST #{URL_BASE}/job/#{JOB_NAME_PATTERN % mod}/config.xml --header \"Content-Type:application/xml\" -d @config.xml.tmp"
puts "Sending data for module #{git_name} with #{cmd}"
res = `#{cmd}`
puts "ERROR: curl exited with non-zero value" if $?.exitstatus != 0
puts case res
when ""
"Succeed"
when /Authentication required/
"ERROR: Wrong Credentials. \n #{res}"
else
"non-standard response: #{res}"
end
end

0 comments on commit 34c0b20

Please sign in to comment.