php - Gitlab CI 和 php 版本
问题描述
我有.gitlab-ci.yml。这里我们刚刚安装了composer。composer.json 需要 php 7.4。
image: php:7.4
stages: # List of stages for jobs, and their order of execution
- test
before_script:
# Install composer dependencies
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
unit_test:
stage: test
script:
- php composer.phar install
- phpunit --configuration phpunit.xml
然后我跑
gitlab-runner exec shell unit_test
在我的本地机器(macos)上并获得:
Problem 1
- Root composer.json requires php ~7.4 but your php version (7.3.29) does not satisfy that requirement.
为什么?为什么是 7.3.29?此外,“图像”设置似乎忽略了版本
解决方案
您必须更新您的项目 composer.json :找到“require”行,它告诉您的项目您需要哪个版本的库
"require": {
"php": "^7.4|^8.0",
},
编辑:如果你需要 7.4 那么你必须在你的 composer.json 中这样写
"require": {
"php": "7.4",
},
解决方案与您使用的版本无关,这是因为您的项目配置(在 composer.json 中)不好
推荐阅读
- python - 仅当上一个函数在 python 中完成时才运行另一个函数
- android - 可以停止在 sqlite 数据库 android 中创建 .db-shm 和 .db-wal 文件吗?
- node.js - 获取引用对象 ID 的项目
- java - 如何在不查看适配器的情况下更改适配器?
- azure - 当解决方案从一个环境迁移到另一个环境时,我们可以更改 Azure 管道中的 SharePoint 列表数据源吗?
- python - 在 Python 中读取 Spark 输出?
- go - 在连接成功mysql时运行命令
- python - psycopg2:“偏移”处或附近的语法错误,日期时间对象
- python - 使用 pyspark 进行约束线性回归
- symfony - Symfony - 我如何从名称以下的请求中获取所有选定的文件