stages:
  - clean
  - dockerbuild
  - dockerpush
  - deploy


variables:
  REGION_id: cn-shenzhen
  REGISTRY: mmc-registry.cn-shenzhen.cr.aliyuncs.com
  NAMESPACE: sharefly-dev
  IMAGE: cms
  TAG: $CI_COMMIT_TAG

  ACR_EE_USERNAME: QD--KeBiTeHangKong@1354706964800968
  ACR_EE_PASSWORD: MMC@2023&ACR
  ACR_EE_REGISTRY: mmc-registry.cn-shenzhen.cr.aliyuncs.com
  ACR_EE_INSTANCE_ID: cri-yhk5zgfc2v1sia6l
  ACR_EE_NAMESPACE: sharefly-dev
  ACR_EE_IMAGE: cms
  ACR_EE_TAG: $CI_COMMIT_TAG
  JAVA_VERSION: '8'
  GITLAB_URL: https://oauth2:MjVJKxB7m4tCy7symBzn@git.mmcuav.cn/iuav/cms.git


mvn_clean:
  stage: clean
  script:
    - echo "清理中ing.........."
    - mvn clean package -Dmaven.test.skip=true --settings /usr/local/maven/apache-maven-3.9.5/conf/settings.xml

docker_build:
  stage: dockerbuild
  script:
    docker build -t $ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG
    docker push $ACR_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG

docker_push:
  stage: dockerpush
  script:
    - docker login --username=$ACR_EE_USERNAME $ACR_EE_REGISTRY
    - docker push $ACR_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG

cms-argocd-deploy:
  stage: deploy
  script:
    cd kustomization/overlays/dev
    kustomize edit set image REGISTRY/NAMESPACE/IMAGE:TAG=$REGISTRY/$NAMESPACE/$IMAGE:$TAG