2

Jenkins build を実行するための PHP スクリプトを作成しました。正常に動作していましたが、セキュリティを適用し、jenkins ビルドを実行できるユーザーを作成しました。

<?php
   echo "Run Jenkins\n";
echo shell_exec("curl -X POST http://198.0.0.21:8080/job/test/build");
echo "\n\n";
?>

今、私はユーザーegtestとパスワードを持っていますtestPHPビルドを実行するための認証としてこのユーザーを使用するようにスクリプトを書き直すにはどうすればよいですか

上記のスクリプトを実行すると、次の出力が得られます。

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");
4

1 に答える 1