0

I'm trying to deploy my GAE app remotely with a URL, and this part works nicely. Jenkins checks out the latest revision correctly but when trying to build with the command specified in the Google Cloud Help:

gcloud --project=<project-id> preview app deploy -q app.yaml

I get the follow error message:

[workspace] $ /bin/sh -xe /opt/bitnami/apache-tomcat/temp/hudson7352698921882428590.sh
+ gcloud --project=XYZXYZXYZ preview app deploy -q app.yaml
/opt/bitnami/apache-tomcat/temp/hudson7352698921882428590.sh: 2:
/opt/bitnami/apache-tomcat/temp/hudson7352698921882428590.sh: gcloud: not found
Build step 'Execute shell' marked build as failure

I have changed the project-id to mine, but i can't figure out why it's missing the gcloud command..

EDIT

I ran

/usr/local/bin/gcloud --project=<project-id> preview app deploy -q app.yaml

and now i got this error:

Traceback (most recent call last):
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 199, in <module>
_cli = CreateCLI()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 197, in CreateCLI
return loader.Generate()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 384, in Generate
cli = self.__MakeCLI(top_group)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 546, in __MakeCLI
log.AddFileLogging(self.__logs_dir)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 546, in AddFileLogging
_log_manager.AddLogsDir(logs_dir=logs_dir)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 330, in AddLogsDir
log_file = self._SetupLogsDir(logs_dir)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 407, in _SetupLogsDir
os.makedirs(day_dir_path)
File "/usr/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/.config'
Build step 'Execute shell' marked build as failure

FINAL EDIT

For anyone comming around here later, i did not exactly solve this, but at least i managed to get around this error by creating an all new VM through the command Google has written in the guide Push-to-Deploy with Jenkins:

$ PASSWORD=<password>                # 12 or more chars, with letters and numbers
$ PROJECT_ID=<project-id>
$ BITNAMI_IMAGE=<bitnami-image>      # e.g. bitnami-jenkins-1-606-0-linux-debian-7-x86-64


$ gcloud compute \
    instances create bitnami-jenkins \
    --project ${PROJECT_ID} \
    --image-project bitnami-launchpad \
    --image ${BITNAMI_IMAGE} \
    --zone us-central1-a \
    --machine-type n1-standard-1 \
    --metadata "bitnami-base-password=${PASSWORD},bitnami-default-user=user,bitnami-key=jenkins,bitnami-name=Jenkins,bitnami-url=//bitnami.com/stack/jenkins,bitnami-description=Jenkins,startup-script-url=https://dl.google.com/dl/jenkins/p2dsetup/setup-script.sh" \
    --scopes "https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/devstorage.full_control,https://www.googleapis.com/auth/projecthosting,https://www.googleapis.com/auth/appengine.admin" \
    --tags "bitnami-launchpad"

At least with this new VM i could move forward and i'm now close to get it working, but i'm stuck on another error which i've created another question for now: Gcloud preview app can't parse my yaml

Community
  • 1
  • 1
MGJ
  • 147
  • 2
  • 12

3 Answers3

2

Try specifying the gcloud executable with its full path - it might not be accessible in jenkins' shell PATH environment.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • This produced another error at least, i updated the original post. I couldn't run sudo from jenkins to fix the .config permission. – MGJ Oct 16 '15 at 07:43
  • OK, at least the original question is addressed :) New problems -> new questions. Now you're into non-GAE-related, jenkins-specific stuff. This seems like a good starting point: http://stackoverflow.com/questions/22814559/how-when-does-execute-shell-mark-a-build-as-failure-in-jenkins. I'm just guessing, but this it looks like a permissions issue when creating a `.config` dir. Sorry - I didn't use jenkins yet. – Dan Cornilescu Oct 16 '15 at 13:53
1

OSError: [Errno 13] Permission denied: '/.config' suggests that 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
Zachary Newman
  • 20,014
  • 4
  • 39
  • 37
  • I set that in my Execute Shell and got: `IOError: [Errno 13] Permission denied: '/tmp/logs/2015.10.17/10.13.48.205831.log'`, still permission errors... damn it. – MGJ Oct 17 '15 at 10:14
  • If i run `id` in my script, it returns: `uid=999(tomcat) gid=999(tomcat) groups=999(tomcat)` – MGJ Oct 17 '15 at 10:25
  • And changing SSH user to tomcat starts with this: `sh: 7: /etc/profile.d/bitnami.sh: source: not found` – MGJ Oct 17 '15 at 10:31
  • `/tmp` was just a suggestion; you can use any directory that the`tomcat` user has write access to. – Zachary Newman Oct 17 '15 at 13:22
  • Yeah, i've been trying, but i can't even grant access to something in `/home/tomcat`, it still comes up as `Permission Denied`, and checking the permissions of the fodlers would lead you to believe tomcat has full access to them.. – MGJ Oct 19 '15 at 06:09
  • `gcloud` uses standard OS mechanisms to make these directories (in this case, Python's `os.makedirs`), so without more information I can't tell you what's wrong. You can try running `python -c 'import os; os.makedirs("/path/to/directory/that/user/should/have/access/to")` and see if that works. – Zachary Newman Oct 19 '15 at 12:14
0

As Dan Cornilescu said, path env variable was not set correctly. Run:

ln -s /var/jenkins_home/google-cloud-sdk/bin/gcloud /usr/local/bin/gcloud

in your worker node to symlink gcloud to global path