我试图让jenkins部署自上次提交以来发生更改的文件。 现在我找到了一个用于执行此操作的脚本here
看了之后相应地更改了东西,我还剩下以下脚本。
<?php
$pathProject = "/var/lib/jenkins/jobs/mysite";
$pathLog = $pathProject."/builds/".$argv[1]."/changelog.xml";
$pathSource = $pathProject."/workspace/";
$pathDestination = $pathProject."/publish";
if (file_exists($pathLog)) {
$xml = simplexml_load_file($pathLog);
$numberOfAuthors = count($xml->logentry);
for ($i = 0; $i < $numberOfAuthors; $i++){
$numberOfAuthorFiles = count($xml->logentry[$i]->paths->path);
for($j = 0; $j < $numberOfAuthorFiles; $j++){
$arrayPath[] = $xml->logentry[$i]->paths->path[$j];
}
}
for ($i = 0; $i < count($arrayPath); $i++){
$path1 = $pathSource . $arrayPath[$i];
$path2 = $pathDestination . $arrayPath[$i];
system("cp $path1 $path2");
}
}
else {
exit("Failed to open $pathLog.");
}
?>
我在我的工作中创建了一个名为&#34; publish&#34;所有已更改的文件都应更改为。
但是当我运行脚本时,我得到以下输出
PHP Warning: simplexml_load_file(): /var/lib/jenkins/jobs/mysite/builds/25/changelog.xml:1: parser error : Start tag expected, '<' not found in /var/lib/jenkins/jobs/mysite/workspace/build_script.php on line 9
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:0
PHP 2. simplexml_load_file() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:9
PHP Warning: simplexml_load_file(): commit dc6f1966e845c408041b126967b2ca27057934bd in /var/lib/jenkins/jobs/mysite/workspace/build_script.php on line 9
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:0
PHP 2. simplexml_load_file() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:9
PHP Warning: simplexml_load_file(): ^ in /var/lib/jenkins/jobs/mysite/workspace/build_script.php on line 9
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:0
PHP 2. simplexml_load_file() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:9
PHP Notice: Trying to get property of non-object in /var/lib/jenkins/jobs/mysite/workspace/build_script.php on line 10
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:0
PHP Notice: Undefined variable: arrayPath in /var/lib/jenkins/jobs/mysite/workspace/build_script.php on line 21
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/jobs/mysite/workspace/build_script.php:0
有谁知道出了什么问题以及我该怎么做才能解决这个问题?我对php有点新鲜,但我想也许这个剧本有些过时了?
这是changelog.xml。我在ubuntu服务器上运行jenkins,所以我ssh到服务器并在vim编辑器中打开了更改日志