variables:
  CORE_BUILD_SUBDIR: legal-core

  AWS_BUILD_SUBDIR: provider/legal-aws/build-aws
  AWS_TEST_SUBDIR: testing/legal-test-aws
  AWS_CHART_SUBDIR: devops/aws/chart
  AWS_SERVICE: legal
  AWS_SERVICE_GATEWAY: osdu-gateway
  AWS_ENVIRONMENT: dev
  AWS_DEPLOY_TARGET: TF
  AWS_EKS_DEPLOYMENT_NAME: os-legal

  IBM_BUILD_SUBDIR: provider/legal-ibm
  IBM_INT_TEST_SUBDIR: testing/legal-test-ibm

  AZURE_SERVICE: legal
  AZURE_BUILD_SUBDIR: provider/legal-azure
  AZURE_TEST_SUBDIR: testing/legal-test-azure
  AZURE_COVERAGE_THRESHOLD: 80
  SERVICE_JAVA_VERSION: "17"

  IBM_HELM_CONFIG_PATH: devops/ibm/ibm-legal-config
  IBM_HELM_DEPLOY_PATH: devops/ibm/ibm-legal-deploy

  # Spotbugs is only intended for Groovy, Scala, or Koitlin development; not Maven+Java
  # The presence of provider/legal-ibm/src/test/resources/logback.groovy is tricking GitLab into including the job
  # We exclude it here to speed up pipeline execution, and avoid having the image fail on our Maven builds
  # Maven jobs should be using semgrep instead
  SAST_EXCLUDED_ANALYZERS: "spotbugs"
  ACCEPTANCE_TEST_DIR: "legal-acceptance-test"

include:
  - project: "osdu/platform/ci-cd-pipelines"
    file: "standard-setup.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "build/maven.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "scanners/fossa-maven.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "scanners/gitlab-ultimate.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/aws-global.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/aws-maven.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/ibm.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/azure.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/gc-global.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/core-global.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/aws-one-pipeline.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/azure-one-pipeline.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/gc-one-pipeline.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "cloud-providers/ibm-one-pipeline.yml"

  - local: "devops/gc/pipeline/override-stages.yml"

  - local: "devops/core-plus/pipeline/override-stages.yml"

  - local: "/publish.yml"

download_plugins:
  image: maven:3.8.3-openjdk-17-slim
  stage: build
  variables:
    OSM_PACKAGE_REGISTRY_URL: "https://community.opengroup.org/api/v4/projects/1448/packages/maven"
    OSM_VERSION: "0.26.0"
    OBM_PACKAGE_REGISTRY_URL: "https://community.opengroup.org/api/v4/projects/1441/packages/maven"
    OBM_VERSION: "0.25.0-rc1"
    OQM_PACKAGE_REGISRTY_URL: "https://community.opengroup.org/api/v4/projects/1450/packages/maven"
    OQM_VERSION: "0.25.0-rc1"

  artifacts:
    paths:
      - ./tmp/*.jar
    when: always
    expire_in: 1 days

  script:
    - mvn dependency:copy -DrepoUrl=$OSM_PACKAGE_REGISTRY_URL -Dartifact="org.opengroup.osdu:os-osm-postgres:$OSM_VERSION:jar:plugin" -Dtransitive=false -DoutputDirectory="./tmp"
    - mvn dependency:copy -DrepoUrl=$OBM_PACKAGE_REGISTRY_URL -Dartifact="org.opengroup.osdu:os-obm-minio:$OBM_VERSION:jar:plugin" -Dtransitive=false -DoutputDirectory="./tmp"
    - mvn dependency:copy -DrepoUrl=$OQM_PACKAGE_REGISRTY_URL -Dartifact="org.opengroup.osdu:os-oqm-rabbitmq:$OQM_VERSION:jar:plugin" -Dtransitive=false -DoutputDirectory="./tmp"

  only:
    variables:
      - $CORE == '1'

azure_deploy:
  variables:
    AZURE_COVERAGE_THRESHOLD: 80

azure_containerize:
  needs: [ "azure-compile-and-unit-test" ]

azure_code_coverage:
  variables:
    AZURE_COVERAGE_THRESHOLD: 80
