“The Google Cloud SDK could not be found in the cu

2019-07-31 23:44发布

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.

3条回答
一夜七次
2楼-- · 2019-08-01 00:03

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.

查看更多
叛逆
3楼-- · 2019-08-01 00:11

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.

查看更多
时光不老,我们不散
4楼-- · 2019-08-01 00:19

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

查看更多
登录 后发表回答