Commit 4138bf59 authored by Fotis Soldatos's avatar Fotis Soldatos
Browse files

Merge branch 'fix-automation-ci' into 'develop'

ci: fix automation .gitlab-ci.yml

See merge request teraflow-h2020/controller!60
parents 0cf897ce cf352edd
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -2,21 +2,24 @@
build automation:
  variables:
    IMAGE_NAME: 'automation' # name of the microservice
    IMAGE_NAME_TEST: 'automation-test' # name of the microservice
    IMAGE_TAG: '0.0.1' # tag of the container image (production, development, etc)
  stage: build
  script:
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target builder
  after_script:
    - docker images --filter="dangling=true" --quiet | xargs -r docker rmi
  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 == "push" && $CI_COMMIT_BRANCH == "develop"'
    - changes:
        - src/$IMAGE_NAME/**
        - manifests/${IMAGE_NAME}service.yaml
        - .gitlab-ci.yml

# Run tests, build & push the image
unit_test automation:
  variables:
    IMAGE_NAME: 'automation' # name of the microservice
    IMAGE_NAME_TEST: 'automation-test' # name of the microservice
    IMAGE_TAG: '0.0.1' # tag of the container image (production, development, etc)
  stage: unit_test
  needs:
@@ -28,9 +31,14 @@ unit_test automation:
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target release
    - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
  after_script:
    - docker rm -f $IMAGE_NAME
  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 == "push" && $CI_COMMIT_BRANCH == "develop"'
    - changes:
        - src/$IMAGE_NAME/**
        - manifests/${IMAGE_NAME}service.yaml
        - .gitlab-ci.yml

# Deployment of automation service in Kubernetes Cluster
@@ -45,3 +53,9 @@ deploy automation:
    - 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