我必须使用 PHP 创建网页,用户可以在其中从下拉框中选择参数并在 jenkins 上远程创建/构建作业。
我已使用 CURL 成功登录到 jenkins,但我不知道如何从网页创建作业或配置 config.xml。
有什么建议?
<---登录.php--->
<form action="login_jenkins.php" method="post">
<fieldset>
<input type="text" name="username">
<input name="password">
<button>
Login
</button>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
<---login_jenkins.php--->
<?php
$url="http://jenkinurl/";
$username=$_POST['username'];
$password=$_POST['password'];
$cookies = '/tmp/cookies.txt';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, '$cookie');
curl_setopt($ch, CURLOPT_COOKIEFILE, '$cookie');
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_URL, …Run Code Online (Sandbox Code Playgroud)