stages:
  - clean
  - dockerbuild
  - deploy


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

  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_SHA
  JAVA_VERSION: '8'
  GITLAB_URL: https://oauth2:MjVJKxB7m4tCy7symBzn@git.mmcuav.cn/iuav/cms.git


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

docker_build:
  stage: dockerbuild
  script:
    - echo $ACR_EE_USERNAME
    - echo $ACR_EE_REGISTRY
    - mvn package -Dmaven.test.skip=true --settings /usr/local/maven/conf/settings.xml
    - docker build -t ${ACR_EE_REGISTRY}/${ACR_EE_NAMESPACE}/${ACR_EE_IMAGE}:${TAG} .
    - docker login -u $ACR_EE_USERNAME -p 'MMC@2023&ACR' $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