---
- job:
    name: "elastic+elasticsearch+pull-request+release-tests"
    display-name: "elastic / elasticsearch - pull request release-tests"
    description: "Testing of Elasticsearch pull requests - release-tests"
    workspace: "/dev/shm/elastic+elasticsearch+pull-request+release-tests"
    scm:
      - git:
          refspec: "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*"
          branches:
            - "${ghprbActualCommit}"
    triggers:
      - github-pull-request:
          org-list:
            - elastic
          allow-whitelist-orgs-as-admins: true
          trigger-phrase: '.*run\W+elasticsearch-ci/release-tests.*'
          github-hooks: true
          status-context: elasticsearch-ci/release-tests
          cancel-builds-on-update: true
          excluded-regions:
            - ^docs/.*
          white-list-labels:
            - 'test-release'
          black-list-target-branches:
            - 7.15
            - 6.8
    builders:
      - inject:
          properties-file: '.ci/java-versions.properties'
          properties-content: |
            JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
            RUNTIME_JAVA_HOME=$HOME/.java/$ES_RUNTIME_JAVA
            JAVA8_HOME=$HOME/.java/java8
            JAVA11_HOME=$HOME/.java/java11
            JAVA15_HOME=$HOME/.java/openjdk15
      - shell: |
          #!/usr/local/bin/runbld --redirect-stderr

          # Fetch beats artifacts
          export ES_VERSION=$(grep 'elasticsearch' build-tools-internal/version.properties | awk '{print $3}')
          export BEATS_DIR=$(pwd)/distribution/docker/build/artifacts/beats

          mkdir -p ${BEATS_DIR}
          curl -o "${BEATS_DIR}/metricbeat-${ES_VERSION}-linux-x86_64.tar.gz" https://snapshots-no-kpi.elastic.co/downloads/beats/metricbeat/metricbeat-${ES_VERSION}-SNAPSHOT-linux-x86_64.tar.gz
          curl -o "${BEATS_DIR}/filebeat-${ES_VERSION}-linux-x86_64.tar.gz" https://snapshots-no-kpi.elastic.co/downloads/beats/filebeat/filebeat-${ES_VERSION}-SNAPSHOT-linux-x86_64.tar.gz

          $WORKSPACE/.ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dbuild.snapshot=false \
            -Dtests.jvm.argline=-Dbuild.snapshot=false -Dlicense.key=${WORKSPACE}/x-pack/license-tools/src/test/resources/public.key -Dbuild.id=deadbeef build

Add optional pull request release tests CI job
Add optional pull request release tests CI job
