Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects

Configure Container Scanning in `.gitlab-ci.yml`, creating this file if it does not already exist

Closed Vincent SIMONIN requested to merge set-container-scanning-config-1 into main
+ 24
25
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
#workflow:
# rules:
# - if: "$CI_PIPELINE_SOURCE == 'merge_request_event'"
# - if: "$CI_COMMIT_TAG"
# - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
default:
tags:
- ovh
stages:
- default_validate
- lint
- build
- test
- deliver
include:
- project: 'digit-c4/digitc4-template-cicd'
file: 'gitlab-ci-ansible.yml'
ref: main
- template: Jobs/Container-Scanning.gitlab-ci.yml
lint-job:
stage: lint
before_script:
@@ -34,32 +27,40 @@ lint-job:
after_script:
- deactivate
- rm -rf "$CI_PROJECT_DIR/plugins/venv"
build-job: # This job runs in the build stage, which runs first.
build-job:
stage: build
script:
- ansible-playbook ansible/build.yml
container_scanning:
tags:
- lab
- docker
variables:
CS_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
up-test-env-job:
stage: test
script:
- chmod 600 $ANSIBLE_PRIVATE_KEY_FILE
- env ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_PRIVATE_KEY_FILE="$ANSIBLE_PRIVATE_KEY_FILE" ansible-playbook -i "$TESTING_HOSTS" -u debian ansible/deploy_on_test.yml
run-test-job:
stage: test
before_script:
- chmod 600 $ANSIBLE_PRIVATE_KEY_FILE
ansible-playbook -i "$TESTING_HOSTS" -u debian ansible/deploy_on_test.yml
- python3 -m venv "$CI_PROJECT_DIR/plugins/venv"
- source "$CI_PROJECT_DIR/plugins/venv/bin/activate"
- pip install -r "$CI_PROJECT_DIR/plugins/netbox-rps-plugin/tests/requirements.e2e.txt"
- pip install -r "$CI_PROJECT_DIR/plugins/netbox-cert-plugin/tests/requirements.e2e.txt"
- pip install -r "$CI_PROJECT_DIR/tests/requirements.e2e.txt"
script:
- env HOST="$CI_COMMIT_SHORT_SHA.$HOSTNAME" PORT="$PORT" API_KEY="$API_KEY" pytest -s --junit-xml=tests-report-netbox-rps-plugin.xml "$CI_PROJECT_DIR/plugins/netbox-rps-plugin/tests/"
- env HOST="$CI_COMMIT_SHORT_SHA.$HOSTNAME" PORT="$PORT" API_KEY="$API_KEY" pytest -s --junit-xml=tests-report-netbox-cert-plugin.xml "$CI_PROJECT_DIR/plugins/netbox-cert-plugin/tests/"
- env HOST="$CI_COMMIT_SHORT_SHA.$HOSTNAME" PORT="$PORT" API_KEY="$API_KEY" pytest -s --junit-xml=tests-report-netbox-dist-plugin.xml "$CI_PROJECT_DIR/tests/e2e/"
- env HOST="$CI_COMMIT_SHORT_SHA.$HOSTNAME" PORT="$PORT" API_KEY="$API_KEY" pytest
-s --junit-xml=tests-report-netbox-rps-plugin.xml "$CI_PROJECT_DIR/plugins/netbox-rps-plugin/tests/"
- env HOST="$CI_COMMIT_SHORT_SHA.$HOSTNAME" PORT="$PORT" API_KEY="$API_KEY" pytest
-s --junit-xml=tests-report-netbox-cert-plugin.xml "$CI_PROJECT_DIR/plugins/netbox-cert-plugin/tests/"
- env HOST="$CI_COMMIT_SHORT_SHA.$HOSTNAME" PORT="$PORT" API_KEY="$API_KEY" pytest
-s --junit-xml=tests-report-netbox-dist-plugin.xml "$CI_PROJECT_DIR/tests/e2e/"
after_script:
ansible-playbook -i "$TESTING_HOSTS" -u debian ansible/halt_test.yml
- deactivate
- rm -rf "$CI_PROJECT_DIR/plugins/venv"
artifacts:
@@ -82,7 +83,7 @@ run-robot-test-job:
after_script:
- docker image prune -a -f
- deactivate
- rm -rf "$CI_PROJECT_DIR/plugins/venv"
- rm -rf "$CI_PROJECT_DIR/plugins/venv"
artifacts:
paths:
- reports/*
@@ -111,21 +112,19 @@ run-robot-test-job:
down-test-env-job_always:
when: always
<<: *down-test-env-job
deliver-latest-job:
stage: deliver
variables:
IMAGE_TAG: "latest"
IMAGE_TAG: latest
script:
- ansible-playbook ansible/deliver.yml
only:
- main
- master
deliver-tagged-job:
stage: deliver
variables:
IMAGE_TAG: $CI_COMMIT_TAG
IMAGE_TAG: "$CI_COMMIT_TAG"
script:
- ansible-playbook ansible/deliver.yml
only:
Loading