docker - 在 Gitlab-CI 上部署 jhipster 5.1.0 项目时出现 "./gradlew: Permission denied"

标签 docker jhipster gitlab-ci

我正在使用 jhipster 5.1.0,我使用“jhipster ci-cd”来生成 .gitlab-ci.yml 文件。
我在我公司的私有(private) 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

最佳答案

您需要修改 git repo 的权限。
跑:

git update-index --chmod=+x gradlew

然后提交并推送。

关于docker - 在 Gitlab-CI 上部署 jhipster 5.1.0 项目时出现 "./gradlew: Permission denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51752706/

相关文章:

node.js - 如何将来自容器的所有流量路由到同一个 Kubernetes pod 中的另一个容器?

python - Windows10 的 Docker 运行 django 失败 : Can't open file 'manage.py' : [Errno 2] No such file or directory

java - 如何在产品配置文件中的 jhipster 应用程序上启用 swagger ui?

Jhipster生成代码后报错,Mapper could not be found

continuous-integration - 手 Action 业中的 Gitlab CI/CD 预填充变量

Gitlab CI SAST 在后续阶段访问 gl-sast-report.json 工件

javascript - 如何按顺序执行 Node JS 函数

c# - 新 Visual Studio 2019 中的环境变量为空,但 Visual Studio 2017 中没有

java - 可以使用复合键制作 spring-data-elasticsearch @Document 吗?

ruby-on-rails - gitlab ci错误无法将主机名 "postgres"转换为地址: Name does not resolve