从jenkins job加载到PHP


Loading from jenkins job to PHP

我能够使用Jenkins API通过url http://localhost:1111/job/api/json获取关于我的构建的信息

这个jenkins里面是什么并不重要。

当我使用json文件在我的PC上,我可以得到值,例如在一种方式:

$string = file_get_contents($fileName.'.json');
$json_a = json_decode($string, true);
echo $json_a['something']['somethingdeeper'];

我正在寻找类似的东西,但当然不是文件URL:

$string = file_get_contents('http://localhost:1111/job/api/json');
$json_a = json_decode($string, true);
echo $json_a['something']['somethingdeeper'];

任何想法?没有找到正确的解决方案,谢谢。

如果这是你的Jenkins作业的urlhttp://localhost: 1111/工作/projectx

你应该添加api/json添加url的末尾。

$string = file_get_contents('http://localhost:1111/job/projectx/api/json');
$json_a = json_decode($string, true);
var_dump($json_a);
//echo $json_a['something']['somethingdeeper'];