curl command not found on .gitlab-ci.yml
Asked Answered
C

4

17

I have a .gitlab-ci.yml file. Its creating some docker images and pushing it to AWS ECR.

When I am running curl command to push some artifacts to remote repository it says curl: not found. I am already using openjdk image to do ./gradlew build. Don't know how to install curl on Gitlab runner.

Please guide.

Cinque answered 4/9, 2017 at 5:58 Comment(1)
Please add a minimal .gitlab-ci.yml file for this problemIsolation
C
25

I was able to resolve it by using apk utility.

apk add --update curl && rm -rf /var/cache/apk/*

Or more recently using no-cache:

apk add --no-cache curl
Cinque answered 7/9, 2017 at 17:56 Comment(2)
this one was really useful. Thanks!Peru
I'm getting apk: command not foundScrappy
M
17

If you're using docker:dind, you can do the following as @Abhinav Mutreja mentioned.

image: docker:stable

services:
  - name: docker:dind

stages:
  - example

example:
  stage: example
  before_script:
    - apk add --update curl && rm -rf /var/cache/apk/*
  script:
    - >
      curl google.com
Maurizio answered 17/5, 2019 at 12:50 Comment(0)
O
2

Installing curl in the runner container works. Here is an example:

trigger_xpub_epmc:
  stage: deploy
  image: docker:stable
  before_script:
    - apk add --update curl && rm -rf /var/cache/apk/*
  script:
    - curl -X POST -F token=xxxxx -F ref=master https://gitlab.example.com/api/v4/projects/1934/trigger/pipeline
Oquassa answered 7/2, 2020 at 12:47 Comment(0)
P
0

you need to install curl in before_script by - apt-get update && apt-get install -y curl git jq

before_script:
    - apt-get update && apt-get install -y curl git jq
 script:
    - curl -F document=@"/app-release.apk" 

and to upload to telegram channel

- curl -F document=@"app/build/outputs/apk/release/${APPLICATION_NAME}${APPLICATION_VERSION}.apk" -F caption="${TELEGRAM_MESSAGE_CAPTION}" https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendDocument?chat_id=${TELEGRAM_CHAT_ID}
Pride answered 7/9, 2022 at 14:44 Comment(1)
Why do you install git and jk?Ruthie

© 2022 - 2024 — McMap. All rights reserved.