jenkins远程url构建。携带参数
php版本
post 增加安全
function curl_post($url, $post)
{
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post,
);
curl命令发送post请求带参数
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书下同
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
不带参数
<?php
include_once "lib/fun.php";
$post_data['job'] = "job_name";
$post_data['token'] = "token";
$url = "ip/buildByToken/build";
echo curl_post($url,$post_data);
>
携带参数
<?php
include_once "lib/fun.php";
$post_data['job'] = "{job_name}";
$post_data['token'] = "{token}";
$post_data['userName'] = "1234455";
$url = "{ip:端⼝}/buildByToken/buildWithParameters";
echo curl_post($url,$post_data);
>
完整连接 注意url
也可以⽤web代码、
192.168.3.11:8848/buildByToken/build?job=FlashRegistration&token=6f8ab858888888f844ab5e27a206692 {IP}:{端⼝号}/buildByToken/build?job={Job名称}&token={Token}
然后有同学说了,我的Job有参数,怎么在调⽤Job时传参数,好办,⽤下边的地址
192.168.3.11:8848/buildByToken/buildWithParameters?
job=FlashRegistration&token=6f8ab85afbda2f8f844ab5e27a206692&branch=master
{IP}:{端⼝号}/buildByToken/buildWithParameters?job={Job名称}&token={Token}&{参数名}={参
数值}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。