我正在使用jhipster 5.1.0,我使用“jhipster ci-cd”来生成.gitlab-ci.yml文件 . 我在我公司的私有Ubuntu 18.04LTS服务器上运行Gitlab和Gitlab-CI . 我配置了Gitlab Runner来使用docker执行构建 .

我的.gitlab-ci.yml文件如下(我没有修改它):

image: jhipster/jhipster:v5.1.0

cache:
    key: "$CI_COMMIT_REF_NAME"
    paths:
        - .gradle/wrapper
        - .gradle/caches
stages:
    - build

before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - ./gradlew yarn_install -PnodeInstall --no-daemon

gradle-build:
    stage: build
    script:
        - ./gradlew compileJava -x check -PnodeInstall --no-daemon
        - ./gradlew test -PnodeInstall --no-daemon
        - ./gradlew yarn_test -PnodeInstall --no-daemon
        - ./gradlew bootJar -Pprod -x check -PnodeInstall --no-daemon
    artifacts:
        paths:
            - build/libs/*.jar
# Uncomment following to expire the artifacts after defined period, https://docs.gitlab.com/ee/ci/yaml/README.html#artifacts-expire_in
#       expire_in: 90 day

这是gitlab-ci运行器的输出:

...
Successfully extracted cache
$ export GRADLE_USER_HOME=`pwd`/.gradle
$ ./gradlew compileJava -x check -PnodeInstall --no-daemon
/bin/bash: line 60: ./gradlew: Permission denied
ERROR: Job failed: exit code 1

由于问题似乎很明显,我试图在“before_script”部分中的“.gradlew”调用之前添加“ - chmod x gradlew” . 我认为这是一个好主意,因为它是在5.1.0之前由“jhipster ci-cd”命令生成的,但现在不再存在了 . 没有成功:Gitlab-CI输出如下:

...
Successfully extracted cache
$ export GRADLE_USER_HOME=`pwd`/.gradle
$ chmod +x gradlew
chmod: changing permissions of 'gradlew': Operation not permitted
ERROR: Job failed: exit code 1

所以我试图在.gitlab-ci.yml文件中切换到docker图像“openjdk:8”而不是“jhipster / jhipster:v5.1.0” . 更好的是,gradle运行“yarn install”命令,但它在某些时候停止,因为该容器不包含“libpng-dev”(最近添加到jhipster容器中,没有运气!):

...
[5/5] Building fresh packages...
error An unexpected error occurred: 
"/builds/epigone/exportCCN/node_modules/pngquant-bin: Command failed.
Exit code: 1
Command: sh
Arguments: -c node lib/install.js
Directory: /builds/epigone/exportCCN/node_modules/pngquant-bin
Output:
⚠ The `/builds/epigone/exportCCN/node_modules/pngquant-bin/vendor/pngquant` 
binary doesn't seem to work correctly
   ⚠ pngquant pre-build test failed
   ℹ compiling from source
   ✔ pngquant pre-build test passed successfully
   ✖ Error: pngquant failed to build, make sure that libpng-dev is installed
      at Promise.all.then.arr (/builds/epigone/exportCCN/node_modules/pngquant-bin/node_modules/bin-build/node_modules/execa/index.js:231:11)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)".
info If you think this is a bug, please open a bug report with the information provided in "/builds/epigone/exportCCN/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
:yarn_install FAILED