Missing Builds When Updating Config.xml through API

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Missing Builds When Updating Config.xml through API

Soula, William
Missing Builds When Updating Config.xml through API I was trying to use the api to reset the formatted version number from the Version Number Plugin and am seeing some weirdness where the latest build is not accessible.  So, I created a new job to test out what was going on and to make sure nothing else was affecting it.  Below are the steps I took:

I created a new job
Restricted where it could run
Setup SVN to always check out a fresh copy
Then setup the version number to have an environment variable name of jenkins.version and format string of ${BUILDS_ALL_TIME} and set the project start date to 2011-08-16
Then have the build invoke ant.

My script that hits the api is pretty much all the ant script does besides getting groovy from ivy and setting up the groovy classpath

The first time the job runs it gets this error: The element type "HR" must be terminated by the matching end-tag "</HR>".
The second time it runs I can see the progress bar in the build history and then the job disappears and if I reload the page there is now build #2
The third time it runs the same thing happens but if I refresh the page then build #2 appears

What is going on?  Why is the latest build hidden till a new build occurs?  What am I doing wrong?

Here is the groovy code I am running from ant:
<groovy>
import org.apache.commons.httpclient.*
import org.apache.commons.httpclient.auth.*
import org.apache.commons.httpclient.methods.*
import groovy.util.XmlSlurper
import groovy.xml.StreamingMarkupBuilder
import groovy.xml.XmlUtil
       
job="Test_API_Post"
def client = new HttpClient()
client.state.setCredentials(
       new AuthScope("jenkins",8080,"realm"),
       new UsernamePasswordCredentials("[redacted]","[redacted]")
)
client.params.authenticationPreemptive=true
def get = new GetMethod("http://jenkins:8080/hudson/job/"+job+"/config.xml")
get.doAuthentication=true
client.executeMethod(get)
response=get.getResponseBodyAsString()
System.out.println response
get.releaseConnection()
def responseXmlSlurper=new XmlSlurper().parseText(response)
responseXmlSlurper.buildWrappers."org.jvnet.hudson.tools.versionnumber.VersionNumberBuilder".oBuildsAllTime=1
response2=XmlUtil.serialize(new StreamingMarkupBuilder().bind{out&lt;&lt;responseXmlSlurper})
System.out.println response2

get=new PostMethod("http://jenkins:8080/hudson/job/"+job+"/config.xml")
RequestEntity entity = new StringRequestEntity(response2,"text/xml","UTF-8")
get.setRequestEntity(entity)
result=client.executeMethod(get)
System.out.println result
</groovy>

Thanks,
Will