Commit 6ead3e74 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

CI/CD pipeline

- updated pipeline to meet requirements and dependencies
parent 83d1d42a
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -16,11 +16,14 @@
stages:
  #- dependencies
  - build
  - build
  - test
  - unit_test
  - integ_test
  - deploy
  - funct_test
  - unit_test_stage1
  - unit_test_stage2
  - unit_test_stage3
  - unit_test_stage4
  #- deploy
  #- end2end_test

# include the individual .gitlab-ci.yml of each micro-service
include:
@@ -30,12 +33,12 @@ include:
  - local: '/src/context/.gitlab-ci.yml'
  - local: '/src/device/.gitlab-ci.yml'
  - local: '/src/service/.gitlab-ci.yml'
  - local: '/src/dbscanserving/.gitlab-ci.yml'
  - local: '/src/opticalattackmitigator/.gitlab-ci.yml'
  - local: '/src/opticalcentralizedattackdetector/.gitlab-ci.yml'
  #- local: '/src/dbscanserving/.gitlab-ci.yml'
  #- local: '/src/opticalattackmitigator/.gitlab-ci.yml'
  #- local: '/src/opticalcentralizedattackdetector/.gitlab-ci.yml'
  - local: '/src/automation/.gitlab-ci.yml'
  - local: '/src/policy/.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'
+19 −19
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ build automation:
unit_test automation:
  variables:
    REPORTS_CONTAINER: "${IMAGE_NAME}-reports"
  stage: unit_test
  stage: unit_test_stage1
  needs:
    - build automation
  before_script:
@@ -79,22 +79,22 @@ unit_test automation:
        - manifests/${IMAGE_NAME}service.yaml
        - .gitlab-ci.yml

# Deployment of automation service in Kubernetes Cluster
deploy automation:
  stage: deploy
  needs:
    - build automation
    - unit_test automation
  script:
    - kubectl version
    - kubectl get all
    - kubectl delete --ignore-not-found=true -f "manifests/automationservice.yaml"
    - kubectl apply -f "manifests/automationservice.yaml"
    - kubectl delete pods --selector app=automationservice
    - kubectl get all
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
      when: manual
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
      when: manual
## Deployment of automation service in Kubernetes Cluster
#deploy automation:
#  stage: deploy
#  needs:
#    - build automation
#    - unit_test automation
#  script:
#    - kubectl version
#    - kubectl get all
#    - kubectl delete --ignore-not-found=true -f "manifests/automationservice.yaml"
#    - kubectl apply -f "manifests/automationservice.yaml"
#    - kubectl delete pods --selector app=automationservice
#    - kubectl get all
#  rules:
#    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#      when: manual
#    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#      when: manual
+27 −27
Original line number Diff line number Diff line
@@ -39,11 +39,11 @@ build compute:
      - .gitlab-ci.yml

# Apply unit test to the component
unit test compute:
unit_test compute:
  variables:
    IMAGE_NAME: 'compute' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: unit_test
  stage: unit_test_stage1
  needs:
    - build compute
  before_script:
@@ -79,28 +79,28 @@ unit test compute:
      reports:
        junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml

# Deployment of the service in Kubernetes Cluster
deploy compute:
  variables:
    IMAGE_NAME: 'compute' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: deploy
  needs:
    - unit test compute
    # - integ_test execute
  script:
    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
    - kubectl get all
  # environment:
  #   name: test
  #   url: https://example.com
  #   kubernetes:
  #     namespace: test
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
      when: manual    
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
      when: manual
## Deployment of the service in Kubernetes Cluster
#deploy compute:
#  variables:
#    IMAGE_NAME: 'compute' # name of the microservice
#    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#  stage: deploy
#  needs:
#    - unit test compute
#    # - integ_test execute
#  script:
#    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
#    - kubectl version
#    - kubectl get all
#    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
#    - kubectl get all
#  # environment:
#  #   name: test
#  #   url: https://example.com
#  #   kubernetes:
#  #     namespace: test
#  rules:
#    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#      when: manual    
#    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#      when: manual
+27 −27
Original line number Diff line number Diff line
@@ -39,11 +39,11 @@ build context:
      - .gitlab-ci.yml

# Apply unit test to the component
unit test context:
unit_test context:
  variables:
    IMAGE_NAME: 'context' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: unit_test
  stage: unit_test_stage1
  needs:
    - build context
  before_script:
@@ -115,28 +115,28 @@ unit test context:
      reports:
        junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml

# Deployment of the service in Kubernetes Cluster
deploy context:
  variables:
    IMAGE_NAME: 'context' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: deploy
  needs:
    - unit test context
    # - integ_test execute
  script:
    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
    - kubectl get all
  # environment:
  #   name: test
  #   url: https://example.com
  #   kubernetes:
  #     namespace: test
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
      when: manual    
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
      when: manual
## Deployment of the service in Kubernetes Cluster
#deploy context:
#  variables:
#    IMAGE_NAME: 'context' # name of the microservice
#    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#  stage: deploy
#  needs:
#    - unit test context
#    # - integ_test execute
#  script:
#    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
#    - kubectl version
#    - kubectl get all
#    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
#    - kubectl get all
#  # environment:
#  #   name: test
#  #   url: https://example.com
#  #   kubernetes:
#  #     namespace: test
#  rules:
#    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#      when: manual    
#    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#      when: manual
+27 −27
Original line number Diff line number Diff line
@@ -39,11 +39,11 @@ build device:
      - .gitlab-ci.yml

# Apply unit test to the component
unit test device:
unit_test device:
  variables:
    IMAGE_NAME: 'device' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: unit_test
  stage: unit_test_stage1
  needs:
    - build device
  before_script:
@@ -79,28 +79,28 @@ unit test device:
      reports:
        junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml

# Deployment of the service in Kubernetes Cluster
deploy device:
  variables:
    IMAGE_NAME: 'device' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: deploy
  needs:
    - unit test device
    # - integ_test execute
  script:
    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
    - kubectl get all
  # environment:
  #   name: test
  #   url: https://example.com
  #   kubernetes:
  #     namespace: test
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
      when: manual    
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
      when: manual
## Deployment of the service in Kubernetes Cluster
#deploy device:
#  variables:
#    IMAGE_NAME: 'device' # name of the microservice
#    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#  stage: deploy
#  needs:
#    - unit test device
#    # - integ_test execute
#  script:
#    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
#    - kubectl version
#    - kubectl get all
#    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
#    - kubectl get all
#  # environment:
#  #   name: test
#  #   url: https://example.com
#  #   kubernetes:
#  #     namespace: test
#  rules:
#    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#      when: manual    
#    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#      when: manual
Loading