我在Jenkins中使用Ant脚本来处理我的文件部署.我想要做的是触发对具有Web服务的URL的调用.我的问题是,我如何从Ant Script或Jenkins中做到这一点?
在此先感谢,Monte
Mar*_*nor 22
Ant的get任务可用于调用Web服务,但它仅限于GET操作.仅适用于非常简单的Web服务
调用unix curl命令来调用webservice(有关示例,请参阅此帖子)
<target name="invoke-webservice">
<exec executable="curl">
<arg line="-d 'param1=value1¶m2=value2' http://example.com/resource.cgi"/>
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
注意:
该卷曲命令也可以援引作为詹金斯后生成作用
如果您需要跨平台且灵活的解决方案,请在构建中嵌入groovy脚本以调用Web服务.
<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>
Run Code Online (Sandbox Code Playgroud)
使用Groovy Postbuild插件调用Web服务.
所述ANT HTTP任务是上述常规任务的替代
| 归档时间: |
|
| 查看次数: |
17696 次 |
| 最近记录: |