zacktzeng
(Zack Tzeng)
August 23, 2022, 8:21pm
1
Hello, I am trying to integrate an existing gitlab repo to sonarqube. However, that repo is using a custom image we built and for some reason I couldn’t add the additional sonarqube .gitlab-ci.yml content to it.
kipping Git submodules setup
Restoring cache
00:01
Checking cache for scan...
FATAL: file does not exist
Failed to extract cache
Executing "step_script" stage of the job script
00:00
$ bootstrap ${CI_RUNNER_SKELETON_KEY_BASE64_TOKEN} ${CI_RUNNER_SKELETON_KEY_ACCOUNT_NAME}
/scripts-5028-2330605/step_script: line 177: bootstrap: command not found
Cleaning up project directory and file based variables
This is some of the error message. Can someone help me with this?
Colin
(Colin)
August 24, 2022, 7:37am
2
What is the full content of your gitlab-ci.yml file?
zacktzeng
(Zack Tzeng)
August 24, 2022, 2:27pm
3
This is the existing .gitlab-ci.yml. It has its own image.
image: gcr.io/t/terraform:
services:
- docker:18-dind
variables:
DOCKER_DRIVER:
DOCKER_HOST:
PROJECT:
REGION:
CLUSTER:
NAMESPACE:
DOCKER_TLS_CERTDIR:
TF_PLUGIN_DIR:
TF_GET_PLUGINS:
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: 0
stages:
- test
- plan
- manual-apply
- manual-destroy
before_script:
- bootstrap ${CI_RUNNER_SKELETON_KEY_BASE64_TOKEN} ${CI_RUNNER_SKELETON_KEY_ACCOUNT_NAME}
- terraform-robot $PROJECT $REGION $CLUSTER $NAMESPACE
- export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.gcloud/terraform_robot_credentials.json
lint:
stage: test
script:
- make init && make test
plan:
stage: plan
script:
- make init && make ci-plan
artifacts:
paths:
- tfplan
expire_in: 1 month
apply:
stage: manual-apply
dependencies:
- plan
script:
- make init && make ci-apply
when: manual
only:
refs:
- main
destroy:
stage: manual-destroy
script:
- make init && make ci-destroy
allow_failure: true
dependencies:
- plan
when: manual
only:
refs:
- main
Colin
(Colin)
August 24, 2022, 2:30pm
4
And how does it look when you try and add the additional SonarQube content?
zacktzeng
(Zack Tzeng)
August 24, 2022, 3:33pm
5
image: gcr.io/t/terraform:
services:
- docker:18-dind
variables:
DOCKER_DRIVER:
DOCKER_HOST:
PROJECT:
REGION:
CLUSTER:
NAMESPACE:
DOCKER_TLS_CERTDIR:
TF_PLUGIN_DIR:
TF_GET_PLUGINS:
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: "0"
stages:
- scan
- test
- plan
- manual-apply
- manual-destroy
before_script:
- bootstrap ${CI_RUNNER_SKELETON_KEY_BASE64_TOKEN} ${CI_RUNNER_SKELETON_KEY_ACCOUNT_NAME}
- terraform-robot $PROJECT $REGION $CLUSTER $NAMESPACE
- export GOOGLE_APPLICATION_CREDENTIALS=
scan:
stage: scan
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner -Dsonar.projectKey=security_italpha_drawio_AYLQdxtpP_KkG93sb6Ht -Dsonar.qualitygate.wait=true
allow_failure: true
only:
- merge_requests
- master # or the name of your main branch
- develop
lint:
stage: test
script:
- make init && make test
plan:
stage: plan
script:
- make init && make ci-plan
artifacts:
paths:
- tfplan
expire_in: 1 month
apply:
stage: manual-apply
dependencies:
- plan
script:
- make init && make ci-apply
when: manual
only:
refs:
- main
destroy:
stage: manual-destroy
script:
- make init && make ci-destroy
allow_failure: true
dependencies:
- plan
when: manual
only:
refs:
- main
zacktzeng
(Zack Tzeng)
August 24, 2022, 3:40pm
6
@Colin the error message seems to suggest that the cache file cannot be found. This doesn’t make sense because I’ve included the variables already.
zacktzeng
(Zack Tzeng)
August 26, 2022, 1:43pm
7
Thanks for the help. This question can be closed now. It turned out that the existing .gitlab-ci.yml file contains a before_script block and the sonar scan job doesn’t support it. So overriding the before_script block in sonar scan job resolved the issue.
system
(system)
Closed
September 2, 2022, 1:43pm
8
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.