我编写了一个 PHP 脚本来运行 Jenkins build 。它工作正常,但现在我应用了一些安全性并创建了可以运行 jenkins 构建的用户。
<?php
echo "Run Jenkins\n";
echo shell_exec("curl -X POST http://198.0.0.21:8080/job/test/build");
echo "\n\n";
?>
现在我有一个用户,例如test
和密码test
。如何重写我的PHP
脚本以使用此用户作为身份验证来运行构建
运行上述脚本时,我得到以下输出:
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
我找到了解决方案:
$u="test";
$p="test";
echo shell_exec("curl -X POST http://$u:$p@198.0.0.21:8080/job/test/build");