How to Integrate doctl with Jenkins CICD?

I’m trying to use doctl with a jenkins pipeline script to push a docker image to my digitalocean image registry and I’m having a lot of trouble.

I’ve downloaded and installed the doctl util via git (since the snap installation wasn’t working) and I’m unable to initialize the authentication.

here is what my steps look like in the script

steps {
  sh 'doctl auth init'
  sh 'doctl registry login'

and this is the error I’m recieving

+ doctl auth init
Error: Unable to read DigitalOcean access token: unknown terminal

I’ve logged into the machine via ssh and switched to the jenkins user and manually initialized auth but unfortunately this doesn’t carry over to the script.

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @decapo01,

I see you’ve managed to find the solution in Githut! Thank you for sharing it in the community as well!

That’s a nice trick using it with Jenkins, I’ll have to try it out for myself as well.

I found the answer here if you do not specify the token in the command the doctl util will try to determine the terminal. Since this is going through Jenkins there is no terminal so I supplied the token in the script

sh 'doctl auth init -t {token}'