Loading .gitlab-ci.yml +8 −2 Original line number Diff line number Diff line Loading @@ -20,9 +20,15 @@ stages: - unit_test - end2end_test variables: CI_IMAGE_TAG: "candidate-${CI_COMMIT_SHORT_SHA}" TFS_REGISTRY_IMAGES: "${CI_REGISTRY_IMAGE}" TFS_IMAGE_TAG: "candidate-${CI_COMMIT_SHORT_SHA}" TFS_SKIP_BUILD: "YES" workflow: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' when: always - when: never Loading @@ -44,7 +50,7 @@ include: - local: '/src/policy/.gitlab-ci.yml' - local: '/src/automation/.gitlab-ci.yml' - local: '/src/forecaster/.gitlab-ci.yml' #- local: '/src/webui/.gitlab-ci.yml' - local: '/src/webui/.gitlab-ci.yml' #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' Loading scripts/ci_apply_deploy_specs_overrides.sh 0 → 100755 +26 −0 Original line number Diff line number Diff line #!/usr/bin/env bash # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Source this after a deploy_specs*.sh file in GitLab CI jobs. Deploy specs # intentionally contain final local values; CI overrides them explicitly here. export CI_IMAGE_TAG="${CI_IMAGE_TAG:-candidate-${CI_COMMIT_SHORT_SHA}}" export TFS_REGISTRY_IMAGES="${CI_REGISTRY_IMAGE}" export TFS_IMAGE_TAG="${CI_IMAGE_TAG}" export TFS_SKIP_BUILD="YES" echo "CI deploy-spec overrides:" echo " TFS_REGISTRY_IMAGES=${TFS_REGISTRY_IMAGES}" echo " TFS_IMAGE_TAG=${TFS_IMAGE_TAG}" echo " TFS_SKIP_BUILD=${TFS_SKIP_BUILD}" scripts/ci_cleanup_gitlab_runner.sh +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,10 @@ if [[ -f scripts/prune_old_mr_docker_images.sh ]]; then bash scripts/prune_old_mr_docker_images.sh fi if [[ -f scripts/prune_old_candidate_docker_images.sh ]]; then bash scripts/prune_old_candidate_docker_images.sh fi if [[ "${CI_CLEANUP_CONTAINERLAB}" == "yes" ]] && command -v containerlab >/dev/null 2>&1; then containerlab destroy --all --cleanup || true fi Loading scripts/ci_image_tags.sh 0 → 100755 +24 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -euo pipefail if [[ -z "${CI_COMMIT_SHORT_SHA:-}" ]]; then echo "CI_COMMIT_SHORT_SHA is required to build CI image tags." >&2 exit 1 fi export CI_IMAGE_TAG="${CI_IMAGE_TAG:-candidate-${CI_COMMIT_SHORT_SHA}}" export TFS_IMAGE_TAG="${TFS_IMAGE_TAG:-${CI_IMAGE_TAG}}" scripts/prune_old_candidate_docker_images.sh 0 → 100755 +50 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -euo pipefail MAX_AGE_DAYS="${CANDIDATE_DOCKER_IMAGE_PRUNE_DAYS:-7}" CUTOFF_EPOCH="$(date -u -d "${MAX_AGE_DAYS} days ago" +%s)" IMAGE_REFS_TO_REMOVE="$(mktemp)" trap 'rm -f "${IMAGE_REFS_TO_REMOVE}"' EXIT docker image ls --format '{{.Repository}} {{.Tag}}' | while read -r REPOSITORY TAG; do if [[ "${REPOSITORY}" == "<none>" ]]; then continue fi if [[ ! "${TAG}" =~ ^candidate-[0-9a-fA-F]+(-builder)?$ ]]; then continue fi IMAGE_REF="${REPOSITORY}:${TAG}" CREATED="$(docker image inspect --format '{{.Created}}' "${IMAGE_REF}" 2>/dev/null || true)" if [[ -z "${CREATED}" ]]; then continue fi CREATED_EPOCH="$(date -u -d "${CREATED}" +%s)" if [[ "${CREATED_EPOCH}" -lt "${CUTOFF_EPOCH}" ]]; then echo "${IMAGE_REF}" >> "${IMAGE_REFS_TO_REMOVE}" fi done if [[ ! -s "${IMAGE_REFS_TO_REMOVE}" ]]; then echo "No Docker images tagged 'candidate-*' older than ${MAX_AGE_DAYS} days found." exit 0 fi echo "Removing Docker images tagged 'candidate-*' older than ${MAX_AGE_DAYS} days:" sort -u "${IMAGE_REFS_TO_REMOVE}" sort -u "${IMAGE_REFS_TO_REMOVE}" | xargs --no-run-if-empty docker image rm --force Loading
.gitlab-ci.yml +8 −2 Original line number Diff line number Diff line Loading @@ -20,9 +20,15 @@ stages: - unit_test - end2end_test variables: CI_IMAGE_TAG: "candidate-${CI_COMMIT_SHORT_SHA}" TFS_REGISTRY_IMAGES: "${CI_REGISTRY_IMAGE}" TFS_IMAGE_TAG: "candidate-${CI_COMMIT_SHORT_SHA}" TFS_SKIP_BUILD: "YES" workflow: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' when: always - when: never Loading @@ -44,7 +50,7 @@ include: - local: '/src/policy/.gitlab-ci.yml' - local: '/src/automation/.gitlab-ci.yml' - local: '/src/forecaster/.gitlab-ci.yml' #- local: '/src/webui/.gitlab-ci.yml' - local: '/src/webui/.gitlab-ci.yml' #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' Loading
scripts/ci_apply_deploy_specs_overrides.sh 0 → 100755 +26 −0 Original line number Diff line number Diff line #!/usr/bin/env bash # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Source this after a deploy_specs*.sh file in GitLab CI jobs. Deploy specs # intentionally contain final local values; CI overrides them explicitly here. export CI_IMAGE_TAG="${CI_IMAGE_TAG:-candidate-${CI_COMMIT_SHORT_SHA}}" export TFS_REGISTRY_IMAGES="${CI_REGISTRY_IMAGE}" export TFS_IMAGE_TAG="${CI_IMAGE_TAG}" export TFS_SKIP_BUILD="YES" echo "CI deploy-spec overrides:" echo " TFS_REGISTRY_IMAGES=${TFS_REGISTRY_IMAGES}" echo " TFS_IMAGE_TAG=${TFS_IMAGE_TAG}" echo " TFS_SKIP_BUILD=${TFS_SKIP_BUILD}"
scripts/ci_cleanup_gitlab_runner.sh +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,10 @@ if [[ -f scripts/prune_old_mr_docker_images.sh ]]; then bash scripts/prune_old_mr_docker_images.sh fi if [[ -f scripts/prune_old_candidate_docker_images.sh ]]; then bash scripts/prune_old_candidate_docker_images.sh fi if [[ "${CI_CLEANUP_CONTAINERLAB}" == "yes" ]] && command -v containerlab >/dev/null 2>&1; then containerlab destroy --all --cleanup || true fi Loading
scripts/ci_image_tags.sh 0 → 100755 +24 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -euo pipefail if [[ -z "${CI_COMMIT_SHORT_SHA:-}" ]]; then echo "CI_COMMIT_SHORT_SHA is required to build CI image tags." >&2 exit 1 fi export CI_IMAGE_TAG="${CI_IMAGE_TAG:-candidate-${CI_COMMIT_SHORT_SHA}}" export TFS_IMAGE_TAG="${TFS_IMAGE_TAG:-${CI_IMAGE_TAG}}"
scripts/prune_old_candidate_docker_images.sh 0 → 100755 +50 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -euo pipefail MAX_AGE_DAYS="${CANDIDATE_DOCKER_IMAGE_PRUNE_DAYS:-7}" CUTOFF_EPOCH="$(date -u -d "${MAX_AGE_DAYS} days ago" +%s)" IMAGE_REFS_TO_REMOVE="$(mktemp)" trap 'rm -f "${IMAGE_REFS_TO_REMOVE}"' EXIT docker image ls --format '{{.Repository}} {{.Tag}}' | while read -r REPOSITORY TAG; do if [[ "${REPOSITORY}" == "<none>" ]]; then continue fi if [[ ! "${TAG}" =~ ^candidate-[0-9a-fA-F]+(-builder)?$ ]]; then continue fi IMAGE_REF="${REPOSITORY}:${TAG}" CREATED="$(docker image inspect --format '{{.Created}}' "${IMAGE_REF}" 2>/dev/null || true)" if [[ -z "${CREATED}" ]]; then continue fi CREATED_EPOCH="$(date -u -d "${CREATED}" +%s)" if [[ "${CREATED_EPOCH}" -lt "${CUTOFF_EPOCH}" ]]; then echo "${IMAGE_REF}" >> "${IMAGE_REFS_TO_REMOVE}" fi done if [[ ! -s "${IMAGE_REFS_TO_REMOVE}" ]]; then echo "No Docker images tagged 'candidate-*' older than ${MAX_AGE_DAYS} days found." exit 0 fi echo "Removing Docker images tagged 'candidate-*' older than ${MAX_AGE_DAYS} days:" sort -u "${IMAGE_REFS_TO_REMOVE}" sort -u "${IMAGE_REFS_TO_REMOVE}" | xargs --no-run-if-empty docker image rm --force