“The Google Cloud SDK could not be found in the customary locations and no path was provided.” Jenkins

一笑奈何 提交于 2019-12-12 17:22:29

问题


I am very new to jenkins, but I have searched for an answer for this a couple of days now. I run jenkins on localhost:8080. I have written a program in Java which uses gradle to deploy to Google App Engine cloud. Now I wanted to use Jenkins to build my program in GIT. Building the program with gradle is fine. When I run

./gradlew appengineDeploy

in Execute Shell I get following:

FAILURE: Build failed with an exception.

  • What went wrong:

Execution failed for task ':appengineDeploy'.

The Google Cloud SDK could not be found in the customary locations and no path was provided.

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 9.571 secs

Build step 'Execute shell' marked build as failure Finished: FAILURE

When I run the code locally, without Jenkins, The Google Cloud SDk is found under:

/Users/marioyoussef/Desktop/google-cloud-sdk

And it works perfect, but I have no idea how to load it to jenkins when executing ./gradlew appengineDeploy.


回答1:


Adding the following to the module's build.gradle might help:

appengine.tools.cloudSdkHome="/Users/marioyoussef/Desktop/google-cloud-sdk"

See https://cloud.google.com/appengine/docs/flexible/java/gradle-reference#global_properties:

Optional property to configure the location of the Google Cloud SDK. Typically the plugin finds this in the Cloud SDK when it is installed with gcloud components install app-engine-java.




回答2:


There are two ways to tackle the issue.

  1. Add a symlink/shortcut for Google Cloud SDK The cloud plugin in IDE searches for SDK in some custom locations such as $HOME/google-cloud-sdk. So you can add a symlink in this directory and point it to actual installed location. In your case a shortcut in /Users/marioyoussef named google-cloud-sdk and point it to /Users/marioyoussef/Desktop/google-cloud-sdk

  2. Add a cloudSdkHome property in build.gradle, but this can be troublesome if you share it with others as the might have it on a different location. For that, you can just mention it in README for others to change it. Just add this line in app's build.gradle appengine.tools.cloudSdkHome="/Users/marioyoussef/Desktop/google-cloud-sdk"

Source: GitHub Issues




回答3:


The cloud tries to find the Google Cloud sdk in a set of predefined directories. If it does not find it, it throws an error. What helped me was this:

Adding a shortcut to the home directory solved my problem.



来源:https://stackoverflow.com/questions/49307284/the-google-cloud-sdk-could-not-be-found-in-the-customary-locations-and-no-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!