Im trying to deploy my app from Gitlab CI, here is my gitlab-ci.yml
"Deploy to DigitalOcean":
image: digitalocean/doctl:latest
stage: deploy
needs:
- job: "Test Docker build"
script:
- doctl auth init
- /app/doctl apps create-deployment XXX
only:
- master
Also I added the DIGITALOCEAN_ACCESS_TOKEN
variable with my personal token.
But I got an error
``Successfully extracted cache ``Executing "step_script" stage of the job script 00:00
``Using docker image sha256:16287ffaf3b998b10c7348803f2372d99b9daadc1f5ded9aab957f6b2b34a7e3 for digitalocean/doctl:latest with digest digitalocean/doctl@sha256:d612c781afeb2720393e32312ef19af545b5c69b933a02bcd83e3e2bda874802 ...
``Error: unknown command "sh" for "doctl"
``Run 'doctl --help' for usage.
``Cleaning up project directory and file based variables 00:01
``ERROR: Job failed: exit code 255
How can I trigger DigitalOcean from my CI pipeline? I don’t want to use deploy_on_push
feature, because it ignores my pipelines and deploy app even when my CI/CD is red.
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!
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.
I had to mix the @Bobby Iliev answer and hint from this SO answer.
Here is the final
gitlab-ci.yml
job:Hi there,
As you are getting
Error: unknown command "sh" for "doctl"
, I think that you need to update the firstdoctl
line from:To:
Let me know how it goes!
Best,
Bobby
deploy: stage: deploy image: name: digitalocean/doctl:1.97.1 entrypoint: [“”] script: - /app/doctl auth init - /app/doctl compute droplet create my-app --image docker-18-04 --size s-1vcpu-1gb --region nyc1 only: - main