Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"./gradlew: Permission denied" when deploying a jhipster 5.1.0 project on Gitlab-CI

I am using jhipster 5.1.0, I used "jhipster ci-cd" in order to generate the .gitlab-ci.yml file. I am running Gitlab and Gitlab-CI on a private Ubuntu 18.04LTS server in my company. I configured the Gitlab Runner to execute the builds with docker.

My .gitlab-ci.yml file is as follows (I did not modify it much):

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

Here is the output of the gitlab-ci runner:

...
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

As the problem seems obvious, I tried to add " - chmod +x gradlew", before the ".gradlew" call in the "before_script" section. I thought it would be a good idea, because it was generated by the "jhipster ci-cd" command before 5.1.0, but not anymore. No success: Gitlab-CI output became as follows:

...
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

So I tried to switch to the docker image "openjdk:8" instead of "jhipster/jhipster:v5.1.0", in the .gitlab-ci.yml file. Much better, gradle runs the "yarn install" command, but it stops at some point, because that container does not contain "libpng-dev" (which was added recently into the jhipster container, no luck !):

...
[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
like image 459
PositronBeam Avatar asked Aug 08 '18 17:08

PositronBeam


1 Answers

You need to modify the permissions on your git repo. Run:

git update-index --chmod=+x gradlew

then commit and push.

like image 52
Megadec Avatar answered Nov 06 '22 23:11

Megadec