简体   繁体   English

如何从 Jenkins 调用 REST API 到外部服务器

[英]How to call REST API to external server from Jenkins

I want to implement that when a build is performed in Jenkins, call my server Rest API.我想实现,当在 Jenkins 中执行构建时,调用我的服务器 Rest API。

Calling Jenkins REST API on my server to perform Build was successful.在我的服务器上调用 Jenkins REST API 以执行构建成功。

在此处输入图像描述

How to call external server REST API in Jenkins?如何在 Jenkins 中调用外部服务器 REST API? is it impossible?不可能吗?

There are multiple ways to do this.有多种方法可以做到这一点。 One option is, you can use something like the HTTP Request Plugin .一种选择是,您可以使用HTTP Request Plugin之类的东西。 Then in your Post step, you can do the HTTP request like below.然后在您的Post步骤中,您可以执行如下所示的 HTTP 请求。

def response = httpRequest 'https://your_host/something'

Another option is to simply use something like curl to send an HTTP request.另一种选择是简单地使用curl类的东西来发送 HTTP 请求。 You can execute your curl command within a sh block.您可以在sh块中执行curl命令。

sh "curl -vk https://your_host/something"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM