Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Created January 28, 2013 08:51
Show Gist options
  • Save kiy0taka/4654002 to your computer and use it in GitHub Desktop.
Save kiy0taka/4654002 to your computer and use it in GitHub Desktop.
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.5.2' )
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
def jobName = 'hello2'
def contentXml = '''
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command>echo hello</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
'''
def http = new HTTPBuilder("http://localhost:8080")
http.post(requestContentType:XML, path:'createItem', query:[name: jobName], body:contentXml) { res ->
println "Done!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment