Option 1: get task
Ant to get the task can be used to call web services, but it is limited to GET operations. Only works for very simple web services.
Option 2: curl
Call the unix curl command to invoke the web service (see post examples)
<target name="invoke-webservice"> <exec executable="curl"> <arg line="-d 'param1=value1¶m2=value2' http://example.com/resource.cgi"/> </exec> </target>
Note:
The curl command can also be called as a post post action in Jenkins
Option 3: Groovy ANT Task
If you need a cross platform and flexible solution, embed a Groovy script in your assembly to invoke the web service.
<target name="invoke-webservice"> <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/> <groovy> import static groovyx.net.http.ContentType.JSON import groovyx.net.http.RESTClient def client = new RESTClient("http://localhost:5498/") def response = client.put(path: "parking_tickets", requestContentType: JSON, contentType: JSON) log.info "response status: ${response.status}" </groovy> </target>
Option 4: Groovy Jenkins post build
Use the Groovy Postbuild plugin to invoke a web service.
Option 5: ANT HTTP Task
Ant HTTP task is an alternative to Groovy task above
source share