env:
  CIRRUS_CLONE_DEPTH: "50"
  CIRRUS_SHELL: bash

  ARTIFACTORY_URL: VAULT[development/kv/data/repox data.url]
  ARTIFACTORY_PRIVATE_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader
  ARTIFACTORY_PRIVATE_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
  SLACK_TOKEN: VAULT[development/kv/data/slack data.token]
  SLACK_CHANNEL: squad-ide-intellij-family-bots
  GRADLE_VERSION: "8.9"
  GRADLE_USER_HOME: ${CIRRUS_WORKING_DIR}/.gradle_cache
  IDEA_HOME: "/opt/intellij"
  RIDER_HOME: "/opt/rider"
  RESHARPER_HOME: "/opt/resharper"
  CLION_HOME: "/opt/clion"

auto_cancellation: $CIRRUS_BRANCH != $CIRRUS_DEFAULT_BRANCH

only_if_nightly: &ONLY_IF_NIGHTLY
  only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && $CIRRUS_CRON == "nightly"

only_pr_and_maintained_branches_including_nightly: &ONLY_PR_AND_MAINTAINED_BRANCHES_INCLUDING_NIGHTLY
  skip: "changesIncludeOnly('*.txt', '**/README.md')"
  only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == ""
    && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH || $CIRRUS_BRANCH == "ci-images-verifier" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "dogfood-on-.*")

only_pr_and_maintained_branches: &ONLY_PR_AND_MAINTAINED_BRANCHES
  skip: "changesIncludeOnly('*.txt', '**/README.md')"
  only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == ""
    && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH == "ci-images-verifier" || $CIRRUS_BRANCH =~ "dogfood-on-.*") && $CIRRUS_BUILD_SOURCE != "cron"

only_main_branches: &ONLY_MAIN_BRANCHES
  skip: "changesIncludeOnly('*.txt', '**/README.md')"
  only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH || $CIRRUS_BRANCH =~ "branch-.*") && $CIRRUS_BUILD_SOURCE != "cron"

orchestrator_monthly_cache_template: &ORCHESTRATOR_MONTHLY_CACHE_TEMPLATE
  set_orchestrator_home_script: |
    export THIS_MONTH=$(date '+%Y-%m')
    echo "THIS_MONTH=${THIS_MONTH}" >> $CIRRUS_ENV
    echo "ORCHESTRATOR_HOME=${CIRRUS_WORKING_DIR}/orchestrator/${THIS_MONTH}" >> $CIRRUS_ENV
  mkdir_orchestrator_home_script: |
    echo "Create dir ${ORCHESTRATOR_HOME} if needed"
    mkdir -p ${ORCHESTRATOR_HOME}
  orchestrator_cache:
    folder: ${ORCHESTRATOR_HOME}
    fingerprint_script: echo ${THIS_MONTH}

container_definition: &CONTAINER_DEFINITION
  image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-g7-latest
  region: eu-central-1
  cluster_name: ${CIRRUS_CLUSTER_NAME}
  namespace: default

eks_builder_container: &BUILDER_CONTAINER_DEFINITION
  <<: *CONTAINER_DEFINITION
  dockerfile: .cirrus/Dockerfile
  docker_arguments:
    CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
    JDK_VERSION: ${JDK_VERSION}
  builder_role: cirrus-builder
  builder_image: docker-builder-v*
  builder_instance_type: t3.small
  builder_subnet_id: ${CIRRUS_AWS_SUBNET}

ec2_instance_definition: &WINVM_DEFINITION
  region: eu-central-1
  type: c5.4xlarge
  image: sonarlint-intellij-v*
  platform: windows

setup_gradle_cache_template: &SETUP_GRADLE_CACHE
  gradle_cache:
    folder: ${GRADLE_USER_HOME}/caches
    fingerprint_script:
      - echo $CIRRUS_OS
      - cat **/*.gradle* gradle/wrapper/gradle-wrapper.properties || true
    populate_script:
      - mkdir -p ${GRADLE_USER_HOME}/caches

cleanup_gradle_cache_script_template: &CLEANUP_GRADLE_CACHE_SCRIPT
  cleanup_gradle_script: |
    rm -rf ${GRADLE_USER_HOME}/caches/$GRADLE_VERSION/
    rm -rf ${GRADLE_USER_HOME}/daemon/
    rm -rf ${GRADLE_USER_HOME}/caches/transforms-*
    rm -rf ${GRADLE_USER_HOME}/caches/journal-*
    /usr/bin/find ${GRADLE_USER_HOME}/caches/ -name "*.lock" -type f -delete

build_task:
  #  name: "Build and stage to repox"
  <<: *ONLY_PR_AND_MAINTAINED_BRANCHES_INCLUDING_NIGHTLY
  eks_container:
    <<: *BUILDER_CONTAINER_DEFINITION
    cpu: 9
    memory: 12G
  env:
    SONAR_HOST_URL: VAULT[development/kv/data/next data.url]
    SONAR_TOKEN: VAULT[development/kv/data/next data.token]
    JDK_VERSION: "17"
    ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa
    ARTIFACTORY_DEPLOY_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer
    ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
    ORG_GRADLE_PROJECT_signingKey: VAULT[development/kv/data/sign data.key]
    ORG_GRADLE_PROJECT_signingPassword: VAULT[development/kv/data/sign data.passphrase]
    ORG_GRADLE_PROJECT_signingKeyId: VAULT[development/kv/data/sign data.key_id]
  <<: *SETUP_GRADLE_CACHE
  build_script: |
    source cirrus-env BUILD-PRIVATE
    source .cirrus/use-gradle-wrapper.sh
    source set_gradle_build_version
    regular_gradle_build_deploy_analyze -x build -x sonar :buildPlugin :cyclonedxBom
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  on_failure:
    slack_notification_script: |
      source slack-failure-notification

validate_task:
  #  name: "Run UTs and trigger SonarQube analysis"
  depends_on:
    - build
  <<: *ONLY_PR_AND_MAINTAINED_BRANCHES
  env:
    SONAR_HOST_URL: VAULT[development/kv/data/next data.url]
    SONAR_TOKEN: VAULT[development/kv/data/next data.token]
    JDK_VERSION: "17"
  eks_container:
    <<: *BUILDER_CONTAINER_DEFINITION
    cpu: 7
    memory: 12G
  <<: *SETUP_GRADLE_CACHE
  build_script: |
    source cirrus-env QA
    source .cirrus/use-gradle-wrapper.sh
    PULL_REQUEST_SHA=$GIT_SHA1 regular_gradle_build_deploy_analyze check -x :its:check -x artifactoryPublish sonar jacocoTestReport
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  on_failure:
    reports_artifacts:
      path: "**/reports/**/*"
    junit_artifacts:
      path: "**/test-results/**/*.xml"
      format: junit
    slack_notification_script: |
      source slack-failure-notification

validate_windows_task:
  #  name: "Run unit tests on Windows"
  depends_on:
    - build
  <<: *ONLY_PR_AND_MAINTAINED_BRANCHES
  env:
    JDK_VERSION: "17"
    IDEA_HOME: "/C/Program Files/intellij"
    RIDER_HOME: "/C/Program Files/rider"
    RESHARPER_HOME: "/C/Program Files/resharper"
    CLION_HOME: "/C/Program Files/clion"
  ec2_instance:
    <<: *WINVM_DEFINITION
  <<: *SETUP_GRADLE_CACHE
  # skip unit tests from submodules to allow caching (else cache is too big for Cirrus)
  build_script: |
    source cirrus-env QA
    source .cirrus/use-gradle-wrapper.sh
    ./gradlew :check
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  on_failure:
    reports_artifacts:
      path: "**/reports/**/*"
    junit_artifacts:
      path: "**/test-results/**/*.xml"
      format: junit
    slack_notification_script: |
      source slack-failure-notification

plugin_verifier_task:
  #  name: "Run plugin verifier on all IDEs"
  depends_on:
    - build
  <<: *ONLY_IF_NIGHTLY
  env:
    JDK_VERSION: "17"
    ALLOWED_IDE: "AS|CL|DG|GO|IIU|IIC|IIE|PS|PCP|PCC|PCE|RDCPPP|RD|RM|WS"
  eks_container:
    <<: *BUILDER_CONTAINER_DEFINITION
    cpu: 4
    memory: 10G
  matrix:
    - env:
        IDEA_VERSION: '2022.3.1'
    - env:
        IDEA_VERSION: '2024.3.1'
    - env:
        # It automatically retrieves the latest version available for the given year (likely to be the EAP)
        IDEA_VERSION: '2024'
  <<: *SETUP_GRADLE_CACHE
  sync_script: |
    git fetch origin +refs/heads/master:refs/remotes/origin/master
    git reset --hard refs/remotes/origin/master
  # The versions are retrieved by querying JB API, we only keep the IDE flavors we handle, then we filter by our specified version.
  # Since there can be multiple 2021.3 (2021.3.1, 2021.3.2, etc.) we only keep the latest one.
  build_script: |
    echo "Run plugin verifier on ${IDEA_VERSION}"
    source cirrus-env QA
    source .cirrus/use-gradle-wrapper.sh
    VERSIONS=$(curl -s -L https://jb.gg/intellij-platform-builds-list | jq '.[] | "\(.code) \(.releases[].version)"' | grep -Ew "${ALLOWED_IDE}" | grep "${IDEA_VERSION}" | tr -d '"' | awk '{k=$1} $2>a[k]{a[k]=$2} END{for (i in a) print i, a[i]}' | sort -u | sed 's/ /-/' | paste -s -d',')
    echo ${VERSIONS}
    ./gradlew :runPluginVerifier -PverifierVersions=${VERSIONS}
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  on_failure:
    reports_artifacts:
      path: "**/reports/**/*"
    slack_notification_script: |
      source slack-failure-notification

qa_task:
  #  name: "Run ITs"
  depends_on:
    - build
  <<: *ONLY_PR_AND_MAINTAINED_BRANCHES
  <<: *ORCHESTRATOR_MONTHLY_CACHE_TEMPLATE
  eks_container:
    <<: *BUILDER_CONTAINER_DEFINITION
    cpu: 6
    memory: 16G
  env:
    CLION_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.clion]
    GOLAND_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.goland]
    DATAGRIP_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.datagrip]
    IDEA_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.idea]
    PHPSTORM_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.phpstorm]
    PYCHARM_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.pycharm]
    RIDER_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.rider]
    RUBYMINE_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.rubymine]
    WEBSTORM_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.webstorm]
    ARTIFACTORY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
    GITHUB_TOKEN: VAULT[development/github/token/licenses-ro token]
    DISPLAY: :10
    JDK_VERSION: "17"
    SONARCLOUD_IT_TOKEN: VAULT[development/team/sonarlint/kv/data/sonarcloud-it data.token]
  clionKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/clion.key.b64
    variable_name: CLION_KEY
  golandKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/goland.key.b64
    variable_name: GOLAND_KEY
  datagripKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/datagrip.key.b64
    variable_name: DATAGRIP_KEY
  ideaKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/idea.key.b64
    variable_name: IDEA_KEY
  phpstormKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/phpstorm.key.b64
    variable_name: PHPSTORM_KEY
  pycharmKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/pycharm.key.b64
    variable_name: PYCHARM_KEY
  riderKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/rider.key.b64
    variable_name: RIDER_KEY
  rubymineKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/rubymine.key.b64
    variable_name: RUBYMINE_KEY
  webstormKey_file:
    path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/webstorm.key.b64
    variable_name: WEBSTORM_KEY
  matrix:
    - env:
        IDEA_VERSION: 'IC-2022.3.1'
        QA_CATEGORY: 'Idea2022'
        TEST_SUITE: 'OpenInIdeTests'
    - env:
        IDEA_VERSION: 'IC-2022.3.1'
        QA_CATEGORY: 'Idea2022'
        TEST_SUITE: 'ConnectedAnalysisTests'
    - env:
        IDEA_VERSION: 'IC-2022.3.1'
        QA_CATEGORY: 'Idea2022'
        TEST_SUITE: 'ConfigurationTests'
    - env:
        IDEA_VERSION: 'IC-2022.3.1'
        QA_CATEGORY: 'Idea2022'
        TEST_SUITE: 'Standalone'
    - env:
        IDEA_VERSION: 'IC-2024.1.4'
        QA_CATEGORY: 'Idea2024'
        TEST_SUITE: 'OpenInIdeTests'
    - env:
        IDEA_VERSION: 'IC-2024.1.4'
        QA_CATEGORY: 'Idea2024'
        TEST_SUITE: 'ConnectedAnalysisTests'
    - env:
        IDEA_VERSION: 'IC-2024.1.4'
        QA_CATEGORY: 'Idea2024'
        TEST_SUITE: 'ConfigurationTests'
    - env:
        IDEA_VERSION: 'IC-2024.1.4'
        QA_CATEGORY: 'Idea2024'
        TEST_SUITE: 'Standalone'
    - env:
        IDEA_VERSION: 'IU-2022.3.1'
        QA_CATEGORY: 'IdeaUltimate2022'
    - env:
        IDEA_VERSION: 'IU-2024.1.4'
        QA_CATEGORY: 'IdeaUltimate2024'
    - env:
        IDEA_VERSION: 'PY-2022.3.1'
        QA_CATEGORY: 'PyCharmProfessional2022'
    - env:
        IDEA_VERSION: 'PY-2024.1.4'
        QA_CATEGORY: 'PyCharmProfessional2024'
    - env:
        IDEA_VERSION: 'PC-2022.3.1'
        QA_CATEGORY: 'PyCharmCommunity2022'
    - env:
        IDEA_VERSION: 'PC-2024.1.4'
        QA_CATEGORY: 'PyCharmCommunity2024'
    - env:
        IDEA_VERSION: 'RD-2022.3.1'
        QA_CATEGORY: 'Rider2022'
    - env:
        IDEA_VERSION: 'RD-2024.1.4'
        QA_CATEGORY: 'Rider2024'
    - env:
        IDEA_VERSION: 'PS-2022.3.1'
        QA_CATEGORY: 'PhpStorm2022'
    - env:
        IDEA_VERSION: 'PS-2024.1.4'
        QA_CATEGORY: 'PhpStorm2024'
    - env:
        IDEA_VERSION: 'GO-2022.3.1'
        QA_CATEGORY: 'GoLand2022'
    - env:
        IDEA_VERSION: 'GO-2024.1.4'
        QA_CATEGORY: 'GoLand2024'
    - env:
        IDEA_VERSION: 'CL-2022.3.1'
        QA_CATEGORY: 'CLion2022'
    - env:
        IDEA_VERSION: 'CL-2024.1.4'
        QA_CATEGORY: 'CLion2024'
  <<: *SETUP_GRADLE_CACHE
  xvfb_background_script: |
    /etc/init.d/xvfb start
  prepare_background_script: |
    set -euo pipefail
    echo "Prepare env and start IDE ${IDEA_VERSION}"
    source cirrus-env QA
    source .cirrus/use-gradle-wrapper.sh
    source set_gradle_build_version
    mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:unpack -B -Dartifact=org.sonarsource.sonarlint.intellij:sonarlint-intellij:${PROJECT_VERSION}:zip "-DoutputDirectory=${CIRRUS_WORKING_DIR}/staged-plugin"
    mkdir -p its/build/idea-sandbox/config-uiTest/
    base64 --decode its/build/idea-sandbox/config-uiTest/clion.key.b64 > its/build/idea-sandbox/config-uiTest/clion.key
    base64 --decode its/build/idea-sandbox/config-uiTest/goland.key.b64 > its/build/idea-sandbox/config-uiTest/goland.key
    base64 --decode its/build/idea-sandbox/config-uiTest/datagrip.key.b64 > its/build/idea-sandbox/config-uiTest/datagrip.key
    base64 --decode its/build/idea-sandbox/config-uiTest/idea.key.b64 > its/build/idea-sandbox/config-uiTest/idea.key
    base64 --decode its/build/idea-sandbox/config-uiTest/phpstorm.key.b64 > its/build/idea-sandbox/config-uiTest/phpstorm.key
    base64 --decode its/build/idea-sandbox/config-uiTest/pycharm.key.b64 > its/build/idea-sandbox/config-uiTest/pycharm.key
    base64 --decode its/build/idea-sandbox/config-uiTest/rider.key.b64 > its/build/idea-sandbox/config-uiTest/rider.key
    base64 --decode its/build/idea-sandbox/config-uiTest/rubymine.key.b64 > its/build/idea-sandbox/config-uiTest/rubymine.key
    base64 --decode its/build/idea-sandbox/config-uiTest/webstorm.key.b64 > its/build/idea-sandbox/config-uiTest/webstorm.key
    metacity --sm-disable --replace &
    sleep 10 # give metacity some time to start
    gradle :its:runIdeForUiTests --stacktrace -i -PijVersion=${IDEA_VERSION} -PslPluginDirectory=${CIRRUS_WORKING_DIR}/staged-plugin > ${CIRRUS_WORKING_DIR}/runIdeGradle.log &
  wait_ide_script: |
    echo "Wait for IDE to start"
    .cirrus/wait-for-endpoint.sh http://127.0.0.1:8082 -t 500
  recording_background_script: |
    echo 'Recording tests on video'
    ffmpeg -loglevel warning -f x11grab -video_size 1280x960 -i ${DISPLAY} -codec:v libx264 -r 12 ${CIRRUS_WORKING_DIR}/recording_${IDEA_VERSION}.mp4
  run_its_script: |
    echo "Run ITs on ${IDEA_VERSION}"
    source .cirrus/use-gradle-wrapper.sh
    gradle :its:check --stacktrace -i -PijVersion=${IDEA_VERSION} -PslPluginDirectory=${CIRRUS_WORKING_DIR}/staged-plugin
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  always:
    stop_recording_script: |
      pkill -SIGINT -f ffmpeg
      while pgrep ffmpeg >/dev/null; do sleep 1; done
      /etc/init.d/xvfb stop
    display_log_script:
      - cat ${CIRRUS_WORKING_DIR}/runIdeGradle.log
    test_recording_artifacts:
      path: "${CIRRUS_WORKING_DIR}/recording_${IDEA_VERSION}.mp4"
    log_artifacts:
      path: "its/build/idea-sandbox/system/log"
  on_failure:
    xvfb_log_artifacts:
      path: "${CIRRUS_WORKING_DIR}/Xvfb.out"
    reports_artifacts:
      path: "**/reports/**/*"
    junit_artifacts:
      path: "**/test-results/**/*.xml"
      format: junit
    slack_notification_script: |
      source slack-failure-notification

inspect_orchestrator_cache_task:
  <<: *ONLY_PR_AND_MAINTAINED_BRANCHES
  depends_on: build
  eks_container:
    <<: *CONTAINER_DEFINITION
    cpu: 1
    memory: 2G
  <<: *ORCHESTRATOR_MONTHLY_CACHE_TEMPLATE
  inspect_cache_script: |
    echo "Inspecting cache ${ORCHESTRATOR_HOME}..."
    cd "${ORCHESTRATOR_HOME}"
    ls -l
    find .
    echo "Inspecting cache done."

mend_scan_task:
  depends_on:
    - build
  <<: *ONLY_MAIN_BRANCHES
  eks_container:
    <<: *CONTAINER_DEFINITION
    cpu: 4
    memory: 4G
  env:
    WS_APIKEY: VAULT[development/kv/data/mend data.apikey]
    IDEA_HOME: ""
    RIDER_HOME: ""
    RESHARPER_HOME: ""
    CLION_HOME: ""
  <<: *SETUP_GRADLE_CACHE
  mend_script: |
    source cirrus-env QA
    source .cirrus/use-gradle-wrapper.sh
    source set_gradle_build_version
    source ws_scan.sh
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  allow_failures: "true"
  always:
    ws_scan_artifacts:
      path: "whitesource/**/*"
  on_failure:
    slack_notification_script: |
      source slack-failure-notification

promote_task:
  depends_on:
    - build
    - validate
    - validate_windows
    - qa
    - mend_scan
  <<: *ONLY_PR_AND_MAINTAINED_BRANCHES
  eks_container:
    <<: *CONTAINER_DEFINITION
    cpu: 3
    memory: 4G
  env:
    ARTIFACTORY_PROMOTE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token]
    GITHUB_TOKEN: VAULT[development/github/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promotion token]
    JDK_VERSION: "17"
    IDEA_HOME: ""
    RIDER_HOME: ""
    RESHARPER_HOME: ""
    CLION_HOME: ""
  <<: *SETUP_GRADLE_CACHE
  promote_script: |
    source .cirrus/use-gradle-wrapper.sh
    cirrus_promote_gradle
  <<: *CLEANUP_GRADLE_CACHE_SCRIPT
  on_failure:
    slack_notification_script: |
      source slack-failure-notification

dogfood_task:
  #  name: "Update internal dogfooding plugin repo"
  #  alias: "update_dogfood_repo"
  depends_on:
    - promote
  only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && $CIRRUS_BUILD_SOURCE != "cron"
  eks_container:
    <<: *BUILDER_CONTAINER_DEFINITION
    cpu: 1
    memory: 2G
  env:
    ARTIFACTORY_API_KEY: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token]
    JDK_VERSION: "17"
  dogfood_script: |
    source cirrus-env QA
    source .cirrus/use-gradle-wrapper.sh
    source set_gradle_build_version
    envsubst '$ARTIFACTORY_URL,$PROJECT_VERSION' <.cirrus/updatePlugins-template.xml >updatePlugins.xml
    jfrog rt u updatePlugins.xml sonarsource-public-builds/org/sonarsource/sonarlint/intellij/sonarlint-intellij/ \
      --url "${ARTIFACTORY_URL}" --access-token "${ARTIFACTORY_API_KEY}" --build-name "$CIRRUS_REPO_NAME" --build-number "$BUILD_NUMBER"
  on_failure:
    slack_notification_script: |
      source slack-failure-notification