Kubectl: command not found on Travis

This is my travis config file

travis.yml

sudo: required
services: 
  - docker
env:
  global:
    - SHA-$(git rev-parse HEAD)
    - CLOUDSDK_CORE_DISABLE_PROMPTS=1
before-install:
  - openssl aes-256-cbc -K $encrypted_0c35eebf403c_key -iv $encrypted_0c35eebf403c_iv -in service-account.json.enc -out service-account.json -d
  - curl https://sdk.cloud.google.com | bash > /dev/null
  - source $HOME/google-cloud-sdk/path.bash.inc
  - gcloud components update kubectl
  - gcloud auth activate-service-account --key-file service-account.json
  - gcloud config set project XXX-234104
  - gcloud config set compute/zone asia-south1-a
  - gcloud container clusters get-credentials standard-cluster-1
  - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

deploy:
  provider: script
  script: bash ./deploy.sh
  on: 
    branch: master

i guess the gcloud components update kubectl command is not working. Any ideas?

You should use before_install instead of before-install, please check your syntax before posting issues, as this is the wrong syntax within Travis, and the .travis.yml as a whole. I recommend you reading this.

---
env:
  global:
    - CLOUDSDK_CORE_DISABLE_PROMPTS=1
before_install:
 - curl https://sdk.cloud.google.com | bash > /dev/null
 - source $HOME/google-cloud-sdk/path.bash.inc
 - gcloud components install kubectl

Then of course, it’s speaking with Travis now - and works perfectly, via it’s now before_install and not before-install. So it’s no wonder Kubernetes is not getting called.

The output:

kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.7", GitCom
1 Like
Imprint