Commit 4da6c0cf authored by Maxime Orefice's avatar Maxime Orefice

Propage env variables to codequality

parent 0fd9e9eb
---
title: Propagate ENV variables to codequality template
merge_request: 41318
author:
type: fixed
......@@ -102,6 +102,16 @@ code_quality:
CODE_QUALITY_IMAGE: "registry.example.com/codequality-fork:latest"
```
In [GitLab 13.4 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/11100), you can override the [Code Quality environment variables](https://gitlab.com/gitlab-org/ci-cd/codequality#environment-variables):
```yaml
variables:
TIMEOUT_SECONDS: 1
include:
- Code-Quality.gitlab-ci.yml
```
By default, report artifacts are not downloadable. If you need them downloadable on the
job details page, you can add `gl-code-quality-report.json` to the artifact paths like so:
......
......@@ -9,6 +9,9 @@ code_quality:
DOCKER_TLS_CERTDIR: ""
CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.10-gitlab.1"
needs: []
before_script:
- source lib/gitlab/ci/templates/utils/env.sh
- export SOURCE_CODE=$PWD
script:
- |
if ! docker info &>/dev/null; then
......@@ -17,10 +20,18 @@ code_quality:
fi
fi
- docker pull --quiet "$CODE_QUALITY_IMAGE"
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
- |
docker run \
$(propagate_env_vars \
SOURCE_CODE \
TIMEOUT_SECONDS \
CODECLIMATE_DEBUG \
CODECLIMATE_DEV \
REPORT_STDOUT \
ENGINE_MEMORY_LIMIT_BYTES \
) \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
"$CODE_QUALITY_IMAGE" /code
artifacts:
reports:
......
function propagate_env_vars() {
CURRENT_ENV=$(printenv)
for VAR_NAME; do
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
done
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment