gcloud command not found when trying to deploy automatically from jenkins?

7,440 views
Skip to first unread message

margorjon

unread,
Oct 16, 2015, 5:03:42 AM10/16/15
to google-cloud-sdk
I'm trying to automatically deploy via jenkins in Google Cloud, this is my current Build -> Execute Shell command:

echo "$PATH"
ls
gcloud
--project="hv-match" preview app deploy -q app.yaml

And the error together with the rest of the output i get is:

[workspace] $ /bin/sh -xe /opt/bitnami/apache-tomcat/temp/hudson6024750435138896107.sh
+ echo /opt/bitnami/gradle/bin:/opt/bitnami/git/bin:/opt/bitnami/java/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/sbin:/usr/sbin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
/opt/bitnami/gradle/bin:/opt/bitnami/git/bin:/opt/bitnami/java/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/sbin:/usr/sbin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
+ ls
...
app
.yaml
...
+ gcloud --project=hv-match preview app deploy -q app.yaml
/opt/bitnami/apache-tomcat/temp/hudson6024750435138896107.sh: 4: /opt/bitnami/apache-tomcat/temp/hudson6024750435138896107.sh: gcloud: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

My code checks out okay, latest revision and all, but jenkins can't find gcloud?

Zachary Newman

unread,
Oct 16, 2015, 6:47:44 AM10/16/15
to margorjon, google-cloud-sdk
Where is the Cloud SDK installed on this machine? `gcloud` usually installs to a directory called `google-cloud-sdk/bin`, and I don't see anything like that on your path.

Is this a VM in Google Compute Engine?

--
You received this message because you are subscribed to the Google Groups "google-cloud-sdk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-cloud-sdk.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sdk/a284a2ab-c2d8-493e-a5da-374ed2f3b3c4%40googlegroups.com.

Message has been deleted

margorjon

unread,
Oct 16, 2015, 6:52:45 AM10/16/15
to google-cloud-sdk, marg...@gmail.com
Yes, i forgot to mention that.
This is a Jenkins VM in Google Compute.
If i SSH into it, i can run gcloud, but through jenkins it fails.

Zachary Newman

unread,
Oct 16, 2015, 6:53:05 AM10/16/15
to margorjon, google-cloud-sdk
Can you identify the location of `gcloud` by SSH-ing in and running the command `which gcloud`? Then, in your Jenkins script, you can refer to `gcloud` by its full path.

margorjon

unread,
Oct 16, 2015, 8:41:18 AM10/16/15
to google-cloud-sdk, marg...@gmail.com
I'm getting some weird permission error:

/home/margorjon/google-cloud-sdk/bin/gcloud --project=hv-match preview app deploy -q app.yaml
Traceback (most recent call last):
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 204, in <module>
    _cli
= CreateCLI()
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 202, in CreateCLI
   
return loader.Generate()
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 314, in Generate
    cli
= self.__MakeCLI(top_group)
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 481, in __MakeCLI
    log
.AddFileLogging(self.__logs_dir)
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 539, in AddFileLogging
    _log_manager
.AddLogsDir(logs_dir=logs_dir)
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 329, in AddLogsDir
    log_file
= self._SetupLogsDir(logs_dir)
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 405, in _SetupLogsDir
    files
.MakeDir(day_dir_path)
 
File "/home/margorjon/google-cloud-sdk/./lib/googlecloudsdk/core/util/files.py", line 57, in MakeDir
   
('Please verify that you have permissions to write to the parent '
googlecloudsdk
.core.util.files.Error: Could not create directory [/.config/gcloud/logs/2015.10.16]: Permission denied.

Please verify that you have permissions to write to the parent directory.

Zachary Newman

unread,
Oct 16, 2015, 9:40:50 AM10/16/15
to margorjon, google-cloud-sdk

It would appear that the Jenkins is attempting to use the root directory as a configuration directory, possibly because of an unusual $HOME directory configuration.

Try setting $CLOUDSDK_CONFIG to point to a directory that the Jenkins user has access to:

CLOUDSDK_CONFIG=/tmp /home/margorjon/google-cloud-sdk/bin/gcloud version

--
You received this message because you are subscribed to the Google Groups "google-cloud-sdk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-cloud-sdk.
Reply all
Reply to author
Forward
0 new messages