Skip to content

Install gcloud on CodeShip

srisub edited this page May 22, 2015 · 1 revision

Install gcloud on your VM

In the setup commands area for CodeShip:

  1. Install gcloud:
  • export CLOUDSDK_PYTHON_SITEPACKAGES=1; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl -s https://sdk.cloud.google.com | bash
  1. Reload the shell session:
  • source ~/.bashrc
  1. Make sure the tool was installed:
  • which gcloud
  1. Setup authentication and provide the VM's gcloud tool with the proper permissions
  • gcloud auth login –no-launch-browser
    1. This will pause and give you a code which you can copy
    2. Paste it into a browser on your local machine and perform the authentication there
    3. Copy the final string from your browser back and paste it into the paused screen on the VM and then hit enter ... your authentication is done.
    4. Once authenticated in this way, the machine keeps the credentials until you change them.
    • If worried about losing the info from the above process (can’t think of a reason right now) ... then once the steps are done, save these files from the VM: ~/.config/gcloud/properties and ~/.config/gcloud/credentials locally. Then those can reused later as needed.

    • For example, if you are using Codeship instead of Jenkins, then those files can be created on every build via a one-line echo command in the setup part of the workflow.

echo '{ "data": [...], "file_version": 1}' > ~/.config/gcloud/credentials cat ~/.config/gcloud/credentials # proof that this was done right echo -e '[core]\naccount = pulkitsinghal@gmail.com' > ~/.config/gcloud/properties cat ~/.config/gcloud/properties # proof that this was done right ``` 5. Verify credentials setup

  • gcloud compute instances list --project $YOUR_PROJECT_ID
  • it should show some results if you've setup the credentials properly

Clone this wiki locally