据本指南报道,我已经尝试开始在gitlab上使用phpstan管道。
问题是管道根本不工作(命令'sh‘没有定义),我不知道如何修复它。
这是我的..gitlab ci.yml文件:
stages:
- check
phpstan:
stage: check
image: ghcr.io/phpstan/phpstan
script:
- analyse --no-progress --error-format gitlab > phpstan.json这是管道输出:
Running with gitlab-runner 15.2.0~beta.17.g34ae4a68 (34ae4a68)
on blue-5.shared.runners-manager.gitlab.com/default -AzERasQ
Preparing the "docker+machine" executor
Using Docker executor with image ghcr.io/phpstan/phpstan ...
Pulling docker image ghcr.io/phpstan/phpstan ...
Using docker image sha256:797d91431d4ecb9c7c570d793db215dec2ae01f942b85e4e6e7cf4e07d07c8f2 for ghcr.io/phpstan/phpstan with digest ghcr.io/phpstan/phpstan@sha256:ac693ee977b314976226205631cd9071364f6c84b3b113f0c9404f9d4747a0b5 ...
Preparing environment
00:01
Running on runner--azerasq-project-37231833-concurrent-0 via runner-azerasq-shared-1658326011- 484bb33b...
Getting source from Git repository
00:03
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/balikobot/BalikobotAdmin/.git/
Created fresh repository.
Checking out e4512b17 as feature/ci-pipeline...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:797d91431d4ecb9c7c570d793db215dec2ae01f942b85e4e6e7cf4e07d07c8f2 for ghcr.io/phpstan/phpstan with digest ghcr.io/phpstan/phpstan@sha256:ac693ee977b314976226205631cd9071364f6c84b3b113f0c9404f9d4747a0b5 ...
Command "sh" is not defined.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1发布于 2022-07-20 15:59:16
问题是,phpstan的官方Docker映像使用入口点,Gitlab运行程序使用"sh -c“命令调用该映像。您可以覆盖默认入口点(https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#overriding-the-entrypoint-of-an-image):
phpstan:
stage: check
image:
name: ghcr.io/phpstan/phpstan
entrypoint: [""]
script:
- phpstan analyse我建议对phpstan使用一个带有具体版本的Docker映像(不要使用最新的标签)。
https://devops.stackexchange.com/questions/16320
复制相似问题