JHipster GitLab CI Permission denied - heroku

I use the command "#jhipster ci-cd" to generate the file .gitlab-ci.yml for pushing on Gitlab and deploy to Heroku.
But the maven compile is failed for "./mvnw: Permission denied"
Checking out a5400e45 as master...
Skipping Git submodules setup
Checking cache for master...
FATAL: file does not exist
Failed to extract cache
$ export MAVEN_USER_HOME=`pwd`/.maven
$ ./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v10.13.0 -DnpmVersion=6.4.1 -Dmaven.repo.local=$MAVEN_USER_HOME
/bin/bash: line 73: ./mvnw: Permission denied
ERROR: Job failed: exit code 1
i don't know why the permission is denied.
I use windows 10 for create jhipster project.

In your .gitlab-ci.yml file put:
image: openjdk:8
[ ... ]
before_script:
- chmod +x mvnw
- export MAVEN_USER_HOME=`pwd`/.maven
- ./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v10.13.0 -DnpmVersion=6.4.1 -Dmaven.repo.local=$MAVEN_USER_HOME
- ./mvnw com.github.eirslett:frontend-maven-plugin:npm -Dmaven.repo.local=$MAVEN_USER_HOME

TL;DR;
Run the following command in you local machine under you project folder:
git update-index --chmod=+x mvnw
Make sure that the script chmod +x mvnw is removed from your .gitlab-ci.yml file.
Push the changes and then everything will works fine.
I have tried the solution mentioned in the other answer which is run chmod +x mvnw in before_script part but it does not work because the chmod is not permitted.
This problem has been dicussed in the jhipster generator github repository here. Go through the page then you'll find the solution.

Related

Go get private repo in gitlab CI

When attempting to download private go dependencies in Gitlab CI, I am given the error:
go: gitlab.com/path/to/private/repo#tag: reading gitlab.com/path/to/private/repo/go.mod at revision repo/tag: git ls-remote -q origin in /go/pkg/mod/cache/vcs/b9c14ef4557b9e7a5cee451c4c1a3b7c3f05519199a2d30cb24ae253b6a6fa2b: exit status 128:
remote: The project you were looking for could not be found or you don't have permission to view it.
fatal: repository 'https://gitlab.com/path/to.git/' not found
The .netrc file is set with a known good value, but it doesn't appear to be working correctly in Gitlab CI. I have replaced my own .netrc file with the one I am attempting to use, deleted ~/go/pkg/mod, and ran go mod tidy in my repo which successfully downloaded the private dependencies. Additionally, if I inject the .netrc contents into a docker build, and have the docker file retrieve the dependencies, there are no issues.
This is the simplest .gitlab-ci.yml file that will replicate:
failingJob:
image: golang:1.17-alpine
script:
- apk update && apk add --no-cache git
- echo "${NETRC}" > /root/.netrc
- go mod download
stage: test
variables:
GOPRIVATE: gitlab.com/private-org
workingJob:
image: docker:19.03.12
services:
- docker:19.03.12-dind
script:
- docker build -t my-docker-image --build-arg SHARE_NETRC="$NETRC" --build-arg GOPRIVATE=gitlab.com/private-org -f docker/Dockerfile .
Dockerfile:
FROM golang:1.17-alpine AS BUILDER
ARG SHARE_NETRC
ARG GOPRIVATE
RUN apk update && apk add --no-cache git ca-certificates
COPY . /app/src
ENV GOPRIVATE=${GOPRIVATE}
ENV SHARE_NETRC=${SHARE_NETRC}
RUN echo "${SHARE_NETRC}" > /root/.netrc
WORKDIR /app/src
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/app
FROM scratch
COPY --from=BUILDER /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=BUILDER /go/bin/app /
ENTRYPOINT [ "/app" ]
As you can see, the image used in the Dockerfile is the same as the image used in Job 1. The values for the .netrc file are the same between the jobs, and the location of the file is the same. The only difference I can see between the two jobs is that one is running directly on the runner while the other is in a Docker build context.

Gitlab-runner submodule .../.git/modules/... is not an directory

I have a repository with one submodule. The CI is configured to clone the submodule:
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: normal
I then created two jobs. One job to build on debian and one job build on windows. The debian build job works fine the submodule is cloned and the correct commit is checked out.
build:debian:
image: debian
stage: build
tags:
- linux
- docker
script:
- qmake project.pro
- make
But the windows job fails during cloning the submodule:
build:windows:
image: windows
stage: build
tags:
- windows
- docker
script:
- qmake.exe project.pro -spec win32-msvc "CONFIG+=release" -r
- nmake clean
- jom.exe -j4
The error looks like this:
Cloning into 'C:/builds/group_name/project_name/submodule_name'...
fatal: Invalid path 'C:/builds/group_name/project_name/.git/modules/submodule_name': Not a directory
fatal: clone of 'https://gitlab-ci-token:[MASKED]#gitlab.domain.com/group_name/submodule_name.git' into submodule path 'C:/builds/group_name/project_name/submodule_name' failed
Failed to clone 'submodule_name' a second time, aborting
I did not posted the first try since it is the same error message.
Do someone know this error, has a solution or maybe an idea how to fix or how to debug?

mvnw: Permission denied on JHipster spring boot application

When I try to clone and run jHipster spring boot application using ./mvnw command, it getting an error mvnw: Permission denied. How can I solve it?
if you use dockerfile, you should add chmod +x mvnw
RUN chmod +x mvnw

My Gitlab CI/CD pipeline failing in cache with FATAL: file does not exist error

right now I'm trying to learn CI/CD with Gradle. I'm using GitLab CI's pipeline. With a Gitlab documentation and a little bit search found gilab-ci.yml like this
image: gradle:jdk11
before_script:
- export GRADLE_USER_HOME='pwd'/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
package:
stage: build
script:
- ./gradlew assemble
test:
stage: test
script:
- ./gradlew check
However its not working for my Spring boot application
Gitlab pipline gives me "FATAL: file does not exist" error. I'm thinking its due to caching but everything seems okay in YAML file
Even though "FATAL: file does not exist" is red and bold, it is not failing the build but is just a warning. The actual cause of the failure is a couple of lines below: /bin/bash: line 104: ./gradlew: Permission denied.
To resolve the issue, update the build stage with the following code segment:
package:
stage: build
script:
- chmod +x ./gradlew
- ./gradlew --build-cache assemble

Docker permissions are different when running on CodeBuild

I am using ruby:2.5.1-alpine for my application's container image. When I run make release locally, which runs the following commands:
docker-compose build --pull release
docker-compose up --abort-on-container-exit test
The test stage runs the migrations, linter and specs. It runs without an issues. When I run the same exact command on CodeBuild which is using a aws/codebuild/ruby:2.5.1 as the host environment I get the following error:
Running RuboCop...
Inspecting 82 files
.................................................................................W
Offenses:
bin/console:1:1: W: Lint/ScriptPermission: Script file console doesn't have execute permission.
I checked the git permissions and everything looks kosher:
edit [...master ] git ls-tree HEAD bin/
100755 blob ad9a02fe6ed489beb105295de771cab5fa87a6af bin/console
100755 blob 9d87e9579b9c16c42d65301e8540888e044ba25d bin/run
100755 blob cf5febb7c6dd34aebdb862792fa147d06a9c5764 bin/setup
edit [...master ]
I added a debug statement to see what the permissions are at the time of the tests running and here is where it diverges.
Locally I get:
test_1_4d039799a73c | File permissions for bin/console are
#<File::Stat ino=10432530, **mode=0100755**, nlink=1, uid=1000, gid=1000,...>
And On the CodeBuild server I get:
File permissions for bin/console are
#<File::Stat ino=525319, **mode=0100666**, nlink=1, uid=0, gid=0, ...>
As I pasted the above I also noticed that the UID and the GID are different. So it looks like the permissions are not being set correctly:
RUN addgroup -g 1000 app && adduser -u 1000 -G app -D app
RUN chown -R app:app $APP_ROOT
WORKDIR $APP_ROOT
This was part of the issue:
https://forums.docker.com/t/not-able-to-change-permissions-for-files-and-folders-created-on-mounted-volumes/45769
After removing the volume for the stage that runs on CodeBuild the mid and gig are correct but the permissions themselves are still off.
·[36mcodebuild_1 |·[0m File permissions for bin/console are
#<File::Stat ino=2755035, mode=0100666, nlink=1, uid=1000, gid=1000...>
Not sure how to go about debugging this.

Resources