'jq: command not found in GitLab CI file
In .gitlab-ci.yml
stages:
- test-jq
test-jq:
stage: test-jq
image: ruby:2.5
script:
- apt-get update
- apt-get install -y git jq
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- LAST_COMMIT_SHA=$(
curl -s \
--header "PRIVATE-TOKEN:$CLONE_KEY" \
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/commits/$CI_COMMIT_SHA" |\
jq -r '.parent_ids | del(.[] | select(. == "'$CI_COMMIT_BEFORE_SHA'")) | .[-1]'
)
throwing an error: /bin/bash: line 158: jq: command not found
Solution 1:[1]
Another approach is to set all the installation part before your scripts, as shown here, using before_script
:
image: node:latest
before_script:
- apt-get -qq update
- apt-get install -y jq
That way, you can make sure the environment is correctly set up once your script starts.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VonC |