当我尝试在Jenkins作业中执行docker-compose up
作为shell构建步骤命令时,我收到了响应docker-compose: command not found
。
有谁知道如何解决这个问题?
Jenkins本身就是在CentOS机器上托管的。
我已经添加了用户' jenkins'到了'sudoers'和用户组:root,jenkins,docker。
答案 0 :(得分:8)
将docker-compose可执行文件添加到PATH envvar。或者使用完全指定的路径,例如/usr/local/bin/docker-compose
答案 1 :(得分:2)
你必须在Jenkins环境中安装docker compose。请按照以下链接安装https://docs.docker.com/compose/install/
答案 2 :(得分:0)
我通过在Jenkins文件中设置环境PATH变量来解决此问题,如下所示:
public function package_recommender($restaurant_id, $count, $money)
{
$response = array();
$response['success'] = true;
$response['message'] = "success";
$connection = null;
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
try {
$connection = mysqli_connect("localhost", "root", "", PackageRecommender::DATABASE_NAME);
$sqlQuery1 = "SELECT * FROM food where NOT foodCategory_id=6 And NOT foodCategory_id=7 And NOT foodCategory_id=8 And restaurant_id='$restaurant_id' And stock>='$count' And isActive = 1;";
$result1 = $connection->query($sqlQuery1);
$sqlQuery2 = "SELECT * FROM food WHERE foodCategory_id=7 And restaurant_id = '$restaurant_id' And stock>'$count' And isActive = 1 order by updateDate desc;";
$result2 = $connection->query($sqlQuery2);
$sqlQuery3 = "SELECT * FROM food WHERE foodCategory_id=8 And restaurant_id = '$restaurant_id' And isActive = 1 order by updateDate desc;";
$result3 = $connection->query($sqlQuery3);
$sqlQuery4 = "SELECT * FROM food WHERE foodCategory_id=6 And restaurant_id = '$restaurant_id' And isActive = 1 order by updateDate desc;";
$result4 = $connection->query($sqlQuery4);
$desertArray = $result2->fetch_assoc();
$drinkArray = $result3->fetch_assoc();
$mealArray = $result4->fetch_assoc();
$packagesArray = array();
if ($result1->num_rows > 0) {
$foodArray = $result1->fetch_assoc();
foreach ($foodArray as $key => $foodValue) {
$package = array();
$package['food'] = $foodValue;
if (isset($mealArray[$key])) {
$package['meal'] = $mealArray[$key];
}
if (isset($drinkArray[$key])) {
$package['drink'] = $drinkArray[$key];
}
if (isset($desertArray[$key])) {
$package['desert'] = $desertArray[$key];
}
array_push($packagesArray, $package);
}
$response["package"] = $packagesArray;
}
echo json_encode($response);
} catch (mysqli_sql_exception $e) {
$response['success'] = false;
$response['message'] = "error 101";
die(json_encode($response));
}
}
答案 3 :(得分:0)
这是我所缺少的命令
for (int i = 1; i <= 10 ; i++)
{
int Random = (int)(Math.random()*100);
this.txtOutput.setText("Password:"+ password + Random);
}
我处死了,詹金斯很好