Skip to content

Commit

Permalink
add jenkins tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 9, 2013
1 parent a5d3aa1 commit 31e02bc
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions jenkins_tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/jenkins.yml
6 changes: 6 additions & 0 deletions jenkins_tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Jenkins tools is intended to help with mass operations on ci.opensuse.org.
Tool can be used only if you have account with proper rights.
It is not intended to be distributed in rpm
Usage require reading source code of each tool where is part of configuration
and exaplained how it works (if you can make your quicklier then reading script,
then it is not right tool for you)
65 changes: 65 additions & 0 deletions jenkins_tools/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@1.5.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name></name>
<refspec></refspec>
<url>https://github.com/yast/yast-core.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<ignoreNotifyCommit>false</ignoreNotifyCommit>
<useShallowClone>false</useShallowClone>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<reference></reference>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<includedRegions></includedRegions>
<scmName></scmName>
</scm>
<assignedNode>yast-jenkins</assignedNode>
<canRoam>false</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers>
<hudson.triggers.SCMTrigger>
<spec>H/5 * * * *</spec>
<ignorePostCommitHooks>false</ignorePostCommitHooks>
</hudson.triggers.SCMTrigger>
</triggers>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command>
cd $WORKSPACE; rake osc:commit; cd -
</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
2 changes: 2 additions & 0 deletions jenkins_tools/jenkins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user:
pwd:
29 changes: 29 additions & 0 deletions jenkins_tools/yast-jenkins-create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "fileutils"
require "yaml"

# script for mass create of jobs in our jenkins
# credentials stored in jenkins.yml
# modify `config.xml` if needed ( git path will be automatic modify )
# modify JOB_NAME_PATTERN before use to specify pattern of job to delete

conf = YAML.load(File.read("jenkins.yml"))
USER = conf["user"]
PWD = conf["pwd"]

# %s is replaced by arguments passed to program
JOB_NAME_PATTERN = "yast-%s-master"

ARGV.each do |mod|
#test if module already exist
response_code = `curl -sL -w "%{http_code}" https://#{USER}:#{PWD}@ci.opensuse.org/view/Yast/job/yast-#{mod}-master/ -o /dev/null`
next if response_code == "200"

FileUtils.rm_f "config.xml.tmp"
# now modify config.xml to fit given module
`sed 's/yast-.*\.git/yast-#{mod}.git/' config.xml > config.xml.tmp`

# adress found from https://ci.opensuse.org/api
res = `curl -X POST https://#{USER}:#{PWD}@ci.opensuse.org/createItem?name=#{JOB_NAME_PATTERN % mod} --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/
end
16 changes: 16 additions & 0 deletions jenkins_tools/yast-jenkins-delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# script for mass delete of jobs in our jenkins
# credentials stored in jenkins.yml
# modify JOB_NAME_PATTERN before use to specify pattern of job to delete

require "yaml"

conf = YAML.load(File.read("jenkins.yml"))
USER = conf["user"]
PWD = conf["pwd"]
# %s is replaced by arguments passed to program
JOB_NAME_PATTERN = "yast-%s-test"

ARGV.each do |mod|
# address to delete from http://jenkins-ci.361315.n4.nabble.com/Deleting-a-job-through-the-Remote-API-td3622851.html
`curl -X POST https://#{USER}:#{PWD}@ci.opensuse.org/job/#{JOB_NAME_PATTERN % mod}/doDelete`
end

0 comments on commit 31e02bc

Please sign in to comment.