操作系统:ubuntu20
环境:https://github.com/yeszao/dnmp
在宿主机本地安装的jenkins,在jenkins中设置job,composer install,截取部分输出如下:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 8 installs, 0 updates, 0 removals
- Installing sebastian/code-unit-reverse-lookup (2.0.2): Downloading (connecting...)Downloading (100%) Failed to download sebastian/code-unit-reverse-lookup from dist: /tmp/composer/cache/files/sebastian/code-unit-reverse-lookup does not exist and could not be created.
Now trying to download from source
- Installing sebastian/code-unit-reverse-lookup (2.0.2): Cloning ee51f9bb0c
[RuntimeException]
Failed to clone https://github.com/sebastianbergmann/code-unit-reverse-lookup.git, git was not found, check that it is installed and in your PATH env.
sh: git: not found
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
skipping non-regular file "vendor/bin/carbon"
skipping non-regular file "vendor/bin/commonmark"
skipping non-regular file "vendor/bin/php-parse"
skipping non-regular file "vendor/bin/psysh"
skipping non-regular file "vendor/bin/var-dump-server"
Finished: SUCCESS
直接在宿主机进到相应的项目目录执行composer install显示:
Cannot create cache directory /tmp/composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /tmp/composer/cache/files/, or directory is not writable. Proceeding without cache
[Composer\Downloader\TransportException]
Content-Length mismatch, received 44625 bytes out of the expected 604017
require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
这里的composer命令是通过在.bashrc中添加以下命令实现的:
# php7 composer
composer () {
tty=
tty -s && tty=--tty
docker run \
$tty \
--interactive \
--rm \
--user www-data:www-data \
--volume ~/dnmp/data/composer:/tmp/composer \
--volume $(pwd):/app \
--workdir /app \
dnmp_php composer "$@"
}
提示找不到git,但显然是存在的,搜索发现可能是权限问题,就给~/dnmp/data/composer,还有/var/lib/jenkins/workspace目录改成777,问题解决。