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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With