Hi everyone,
i’m able to execute kubectl over command line in linux, but i get error bellow when running the same command in jenkinsfile. Can anybody help me, please?
Error: Unable to initialize DigitalOcean API client: access token is required. (hint: run ‘doctl auth init’)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @bobbyiliev
Thank you for answering me.
I solved it changing the approaching by using kubernetes plugin.
;)
Hi there @carlosbenicio79,
It is quite possible that your Jenkins service is running as a different user so it does not have access to the Kubernetes config file of your SSH user.
What you could do is add an extra step in your Jenkinsfile to first authenticate with doctl, it would look something like this:
doctl auth init --access-token "your_digitalocean_token"
I would recommend adding your DigitalOcean access token as a Jenkins secret rather than hardcoding it in your Jenkinsfile.
And then add another step to save the Kubernetes config:
doctl kubernetes cluster kubeconfig save use_your_cluster_name
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.