简体   繁体   English

在 jenkins 容器内安装 php 和 composer

[英]install php and composer inside jenkins container

I'm trying to create a Jenkins pipeline that has a 'Test' stage which requires PHP and Composer in order to run the tests with PHPUnit.我正在尝试创建一个 Jenkins 管道,该管道具有“测试”阶段,需要 PHP 和 Composer 才能使用 PHPUnit 运行测试。

How do I install PHP (preferably version 7.4) and Composer inside a Jenkins Docker container?如何在 Jenkins Docker 容器内安装 PHP(最好是 7.4 版)和 Composer?

This is how I tried inside the container's Dockerfile:这就是我在容器的 Dockerfile 中尝试的方法:

FROM jenkins/jenkins

USER root

# install PHP and Composer
RUN apt-get install -y php php-mbstring php-xml php-bcmath && \
    apt-get install -y composer
    
USER jenkins

When I build the image I get this error:当我构建图像时,出现此错误:

Step 3/4 : RUN apt-get install -y php php-mbstring php-xml php-bcmath php-fpm &&     apt-get install -y composer && apt-get install -y vim
 ---> Running in 0b20c56bd720
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package php
E: Unable to locate package php-mbstring
E: Unable to locate package php-xml
E: Unable to locate package php-bcmath
E: Unable to locate package php-fpm

You miss apt-get update before install .您在install之前错过了apt-get update

The sudo apt-get update command is used to download package information from all configured sources sudo apt-get update 命令用于从所有配置的源下载 package 信息

See this .看到这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM