Skip to content
Snippets Groups Projects
Commit a914933d authored by Felix Ohms's avatar Felix Ohms Committed by Manuel Kieweg
Browse files

Resolve "Prevent containerlab:destroy pipeline step from running if not needed"

parent 8cd9d91e
Branches
No related tags found
9 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!195DO NOT MERGE 2,!194DO NOT MERGE! just for testing,!182Resolve "Prevent containerlab:destroy pipeline step from running if not needed",!138Develop
...@@ -40,4 +40,4 @@ build-docker: ...@@ -40,4 +40,4 @@ build-docker:
- docker tag $DOCKER_IMAGE_SHA $TAG - docker tag $DOCKER_IMAGE_SHA $TAG
- docker push $TAG - docker push $TAG
- docker build --target installer --build-arg GITLAB_USER=$GO_MODULES_USER --build-arg GITLAB_TOKEN=$GO_MODULES_ACCESS_TOKEN --build-arg BUILDARGS=$BUILDARGS -t registry.code.fbi.h-da.de/cocsn/gosdn:testing_${CI_PIPELINE_ID} . - docker build --target installer --build-arg GITLAB_USER=$GO_MODULES_USER --build-arg GITLAB_TOKEN=$GO_MODULES_ACCESS_TOKEN --build-arg BUILDARGS=$BUILDARGS -t registry.code.fbi.h-da.de/cocsn/gosdn:testing_${CI_PIPELINE_ID} .
- docker push registry.code.fbi.h-da.de/cocsn/gosdn:testing_${CI_PIPELINE_ID} - docker push registry.code.fbi.h-da.de/cocsn/gosdn:testing_${CI_PIPELINE_ID}
\ No newline at end of file
...@@ -12,4 +12,4 @@ code-quality: ...@@ -12,4 +12,4 @@ code-quality:
reports: reports:
codequality: gl-code-quality-report.json codequality: gl-code-quality-report.json
paths: paths:
- gl-code-quality-report.json - gl-code-quality-report.json
\ No newline at end of file
variables: variables:
CEOS_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE/ceos:latest" CEOS_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE/ceos:latest"
CLAB_INT1_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/int01.clab.yml" CLAB_INT1_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/int01.clab.yml"
...@@ -13,17 +12,6 @@ variables: ...@@ -13,17 +12,6 @@ variables:
- if: $CI_NIGHTLY - if: $CI_NIGHTLY
.containerlab_template: &containerlab_template
tags:
- shell
before_script:
- cd ${CLAB_DIR}
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- echo $DOCKER_IMAGE_SHA
- docker pull $DOCKER_IMAGE_SHA
- docker pull ${CEOS_CONTAINER_IMAGE}
containerlab:template: containerlab:template:
extends: .containerlab_rules extends: .containerlab_rules
image: alpine:latest image: alpine:latest
...@@ -50,10 +38,17 @@ containerlab:template: ...@@ -50,10 +38,17 @@ containerlab:template:
containerlab:deploy: containerlab:deploy:
extends: extends:
- .containerlab_template
- .containerlab_rules - .containerlab_rules
stage: apply stage: apply
needs: ["containerlab:template", "build-docker"] needs: ["containerlab:template", "build-docker"]
tags:
- shell
before_script:
- cd ${CLAB_DIR}
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- echo $DOCKER_IMAGE_SHA
- docker pull $DOCKER_IMAGE_SHA
- docker pull ${CEOS_CONTAINER_IMAGE}
script: script:
- sudo containerlab deploy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml --reconfigure - sudo containerlab deploy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml --reconfigure
- echo "GOSDN_HTTP_PORT=$(docker inspect -f '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' clab-${CLAB_NAME}-gosdn)" >> ${CI_PROJECT_DIR}/build.env - echo "GOSDN_HTTP_PORT=$(docker inspect -f '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' clab-${CLAB_NAME}-gosdn)" >> ${CI_PROJECT_DIR}/build.env
...@@ -66,6 +61,13 @@ containerlab:deploy: ...@@ -66,6 +61,13 @@ containerlab:deploy:
dotenv: ${CI_PROJECT_DIR}/build.env dotenv: ${CI_PROJECT_DIR}/build.env
containerlab:destroy: containerlab:destroy:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop')
when: always
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- if: $CI_NIGHTLY
when: always
stage: .post stage: .post
tags: tags:
- shell - shell
...@@ -78,4 +80,3 @@ containerlab:destroy: ...@@ -78,4 +80,3 @@ containerlab:destroy:
allow_failure: true allow_failure: true
dependencies: dependencies:
- containerlab:template - containerlab:template
when: always
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment