mvnw permission denied in Google Cloud Build
ArcticWalrus opened this issue · 9 comments
I am building a Spring Boot project to run on Cloud Run using the documentation found at : https://cloud.google.com/run/docs/deploying-source-code
The build starts and fails with the following logs :
[builder] Installing Java v11.0.12+7
[builder] --------------------------------------------------------------------------------
[builder] Running "bash -c curl --fail --show-error --silent --location --retry 3 https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz | tar xz --directory /layers/google.java.runtime/java --strip-components=1"
[builder] Done "bash -c curl --fail --show-error --silent --location --retry..." (4.513576044s)
[builder] === Java - Maven (google.java.maven@0.9.0) ===
[builder] --------------------------------------------------------------------------------
[builder] Running "./mvnw clean package --batch-mode -DskipTests -Dhttp.keepAlive=false --quiet"
[builder] Done "./mvnw clean package --batch-mode -DskipTests -Dhttp.keepAli..." (771.271µs)
[builder] Failure: (ID: 7d0b3ca3) executing command "./mvnw clean package --batch-mode -DskipTests -Dhttp.keepAlive=false --quiet": fork/exec ./mvnw: permission denied
[builder] --------------------------------------------------------------------------------
[builder] Sorry your project couldn't be built.
The ./mvnw permission denied being the main issue.
I tried doing the same process in your Quick Start and had the same error.
Please let me know if you require any additional information.
Hi @ArcticWalrus this sounds like an issue with unix file permissions. Can you try running chmod +x ./mvnw
before deploying again?
Hey @matthewrobertson! Thanks for the suggestion.
That is the first thing that I tried
I'm trying to reproduce this using:
https://github.com/GoogleCloudPlatform/buildpack-samples/tree/master/sample-java-mvn
Works:
pack build --builder=gcr.io/buildpacks/builder sample-java-mvn
Works:
gcloud run deploy sample-java-mvn --source .
So I'm not sure what could be different with your setup. Can you see if that project works for you?
@ArcticWalrus are you launching from Windows by any chance?
Can you include the first couple of lines of your mvnw
script? Shell scripts can behave oddly if the shebang (the #!
part) has issues.
Hey! Sorry for the slow response.
I will check the suggestions out this evening or tomorrow at the latest.
Just finished midterms
@jamesward
gcloud run deploy sample-java-mvn --source .
did not work for me. I will install pack and give that a try as well to see if that helps.
@briandealwis
I am currently deploying from windows from a git-bash terminal.
The first line is #!/bin/sh
. It being on windows does not seem to be the issue seeing as I can run ./mvnw clean package --batch-mode -DskipTests
locally, which is the command that is failing in the Cloud Build Logs.
However seeing as the command I am using works for @jamesward , it's probably some config issue with windows or a permissions error on my end in the GCP project.
I gave it a try by deploying a docker image I built on my side instead of deploying from source and that is working.
Might be something specific to using the git-bash terminal. Like maybe it is mucking with file permissions or line endings. I've had great success with WSL.
I can confirm that the original command works in WSL, but not git-bash on my end.
However, as previously mentioned I am able to deploy from an image in the artifact registry without any issues from gitbash
Thanks for the suggestions