Commit 88087caa authored by kesnar's avatar kesnar
Browse files

refactor: gitlab ci job

parent 43954419
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -13,12 +13,12 @@
# limitations under the License.
# limitations under the License.


variables:
variables:
  IMAGE_NAME: 'automation'
  IMAGE_NAME: 'ztp'
  REPORTS_PATH: "src/${IMAGE_NAME}/reports"
  REPORTS_PATH: "src/${IMAGE_NAME}/reports"
  BUILD_ENV: build.env
  BUILD_ENV: build.env


# Package application needed to run tests & build the image on next stage
# Package application needed to run tests & build the image on next stage
build automation:
build ztp:
  stage: build
  stage: build
  script:
  script:
    - export IMAGE_TAG=$(grep -m1 '<version>' ./src/$IMAGE_NAME/pom.xml | grep -oP  '(?<=>).*(?=<)')
    - export IMAGE_TAG=$(grep -m1 '<version>' ./src/$IMAGE_NAME/pom.xml | grep -oP  '(?<=>).*(?=<)')
@@ -39,12 +39,12 @@ build automation:
        - .gitlab-ci.yml
        - .gitlab-ci.yml


# Run tests, build & push the image
# Run tests, build & push the image
unit_test automation:
unit_test ztp:
  variables:
  variables:
    REPORTS_CONTAINER: "${IMAGE_NAME}-reports"
    REPORTS_CONTAINER: "${IMAGE_NAME}-reports"
  stage: unit_test
  stage: unit_test
  needs:
  needs:
    - build automation
    - build ztp
  before_script:
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker rm ${REPORTS_CONTAINER} || true
    - docker rm ${REPORTS_CONTAINER} || true
@@ -79,18 +79,18 @@ unit_test automation:
        - manifests/${IMAGE_NAME}service.yaml
        - manifests/${IMAGE_NAME}service.yaml
        - .gitlab-ci.yml
        - .gitlab-ci.yml


## Deployment of automation service in Kubernetes Cluster
## Deployment of ztp service in Kubernetes Cluster
#deploy automation:
#deploy ztp:
#  stage: deploy
#  stage: deploy
#  needs:
#  needs:
#    - build automation
#    - build ztp
#    - unit_test automation
#    - unit_test ztp
#  script:
#  script:
#    - kubectl version
#    - kubectl version
#    - kubectl get all
#    - kubectl get all
#    - kubectl delete --ignore-not-found=true -f "manifests/automationservice.yaml"
#    - kubectl delete --ignore-not-found=true -f "manifests/ztpservice.yaml"
#    - kubectl apply -f "manifests/automationservice.yaml"
#    - kubectl apply -f "manifests/ztpservice.yaml"
#    - kubectl delete pods --selector app=automationservice
#    - kubectl delete pods --selector app=ztpservice
#    - kubectl get all
#    - kubectl get all
#  rules:
#  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 == $CI_DEFAULT_BRANCH)'