# Declare a Backstage Component that represents your application.
---
# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: elastic-agent
  description: Elastic Agent - single, unified way to add monitoring for logs, metrics, and other types of data to a host.
  annotations:
    sonarcloud.io/project-key: elastic_elastic-agent

spec:
  type: tool
  owner: group:ingest-fp
  system: platform-ingest
  lifecycle: production

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-elastic-agent
  description: Buildkite pipeline for the Elastic Agent project
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent
      description: Buildkite pipeline for the Elastic Agent project
    spec:
      branch_configuration: "main 7.* 8.* 9.*"
      repository: elastic/elastic-agent
      pipeline_file: ".buildkite/pipeline.yml"
      provider_settings:
        build_pull_request_forks: false
        build_pull_requests: true
        build_tags: false
        filter_enabled: true
        # TODO: what's the reason for this filter?
        filter_condition: >-
          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
      schedules:
        Daily main:
          branch: main
          cronline: "0 0 * * 1-5"
          message: Mon-Fri daily build
      cancel_intermediate_builds: true
      cancel_intermediate_builds_branch_filter: "!main !7.* !8.* !9.*"
      skip_intermediate_builds: true
      skip_intermediate_builds_branch_filter: "!main !7.* !8.* !9.*"
      env:
        ELASTIC_PR_COMMENTS_ENABLED: 'true'
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
        SLACK_NOTIFICATIONS_ALL_BRANCHES: "false"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-elastic-agent-testing
  description: Buildkite pipeline for the Elastic Agent extended testing
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent-extended-testing

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent-extended-testing
      description: Buildkite pipeline for the Elastic Agent extended testing
    spec:
      repository: elastic/elastic-agent
      pipeline_file: ".buildkite/integration.pipeline.yml"
      provider_settings:
        trigger_mode: none # don't trigger jobs from github activity
      cancel_intermediate_builds: true
      cancel_intermediate_builds_branch_filter: "!main !7.* !8.* !9.*"
      skip_intermediate_builds: true
      skip_intermediate_builds_branch_filter: "!main !7.* !8.* !9.*"
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
        SLACK_NOTIFICATIONS_ALL_BRANCHES: "false"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-elastic-agent-testing-bk
  description: Elastic Agent extended testing using buildkite agents
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent-extended-testing-bk

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent-extended-testing-bk
      description: Elastic Agent extended testing using buildkite agents
    spec:
      repository: elastic/elastic-agent
      pipeline_file: ".buildkite/bk.integration.pipeline.yml"
      provider_settings:
        trigger_mode: none # don't trigger jobs from github activity
      cancel_intermediate_builds: false
      skip_intermediate_builds: false
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-elastic-agent-package
  description: Buildkite pipeline for packaging Elastic Agent package
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent-package
      description: Buildkite pipeline for packaging Elastic Agent package
    spec:
      repository: elastic/elastic-agent
      pipeline_file: ".buildkite/pipeline.elastic-agent-package.yml"
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
        SLACK_NOTIFICATIONS_ALL_BRANCHES: "true"
      provider_settings:
        build_pull_request_forks: false
        build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
        publish_commit_status: false # do not update status of commits for this pipeline
        build_tags: false
        build_branches: false
        filter_enabled: true
        filter_condition: >-
          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
      cancel_intermediate_builds: true
      cancel_intermediate_builds_branch_filter: "!main !7.* !8.* !9.*"
      skip_intermediate_builds: true
      skip_intermediate_builds_branch_filter: "!main !7.* !8.* !9.*"
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        release-eng:
          access_level: BUILD_AND_READ
        observablt-robots:
          access_level: BUILD_AND_READ
        endpoint-ci-admin:
          access_level: BUILD_AND_READ
        everyone:
          access_level: READ_ONLY

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-elastic-agent-binary-dra
  description: Buildkite pipeline for packaging Elastic Agent core binary and publish it to DRA
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent-binary-dra

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent-binary-dra
      description: Buildkite pipeline for packaging Elastic Agent core binary and publish it to DRA
    spec:
      branch_configuration: "main 7.* 8.* 9.*"
      pipeline_file: ".buildkite/pipeline.elastic-agent-binary-dra.yml"
      provider_settings:
        build_pull_request_forks: false
        build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
        publish_commit_status: false # do not update status of commits for this pipeline
        build_tags: false
        build_branches: true # enable build for branches. This relies on the filter in .buildkite/pipeline.elastic-agent-binary-dra.yml
        filter_enabled: true
        # TODO: what's the reason for this filter?
        filter_condition: >-
          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
      repository: elastic/elastic-agent
      schedules:
        Daily main:
          branch: main
          cronline: "@daily"
          message: Builds daily `main` dra
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-elastic-agent-integration-matrix
  description: Elastic-agent integration tests matrix
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/buildkite-elastic-agent-integration-matrix

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: buildkite-elastic-agent-integration-matrix
      description: Runs elastic-agent integration tests for all supported platforms
    spec:
      pipeline_file: ".buildkite/pipeline.integration-test-matrix.yml"
      provider_settings:
        trigger_mode: none # don't trigger jobs from github activity
      repository: elastic/elastic-agent
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
        SLACK_NOTIFICATIONS_SKIP_FOR_RETRIES: "true"
      schedules:
        weekly:
          branch: main
          cronline: "0 0 * * 4" # every Thursday at 00:00
          message: Integration test matrix
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-elastic-agent-gce-cleanup
  description: Clean up stale GCE instances
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent-gce-cleanup
      description: Pipeline file for cleaning up lingering GCE instances
    spec:
      pipeline_file: ".buildkite/pipeline.elastic-agent-gce-cleanup.yml"
      provider_settings:
        build_pull_request_forks: false
        build_pull_requests: false # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
        publish_commit_status: false # do not update status of commits for this pipeline
        build_tags: false
        build_branches: false
        filter_enabled: true
        # TODO: what's the reason for this filter?
        filter_condition: >-
          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
      repository: elastic/elastic-agent
      schedules:
        Every 4 hours:
          branch: main
          cronline: "0 0/4 * * *" # every 4th hour
          message: GCE cleanup
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-elastic-agent-helm-charts
  description: Elastic-agent Helm Charts Pipeline
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/elastic-agent-helm-charts

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: elastic-agent-helm-charts
      description: Runs elastic-agent helm charts
    spec:
      pipeline_file: ".buildkite/pipeline.elastic-agent-helm-charts.yml"
      provider_settings:
        trigger_mode: none # don't trigger jobs from github activity
      repository: elastic/elastic-agent
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        observablt-robots:
          access_level: MANAGE_BUILD_AND_READ
        observablt-robots-automation:
          access_level: BUILD_AND_READ
        release-eng:
          access_level: BUILD_AND_READ
        # See https://buildkite.com/docs/pipelines/configure/step-types/trigger-step#permissions
        # Otherwise even if merge commits in main or any branch will fail
        everyone:
          access_level: BUILD_AND_READ


---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: beats-agent-serverless-tests
  description: "Beats serverless tests from elastic-agent repository"
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/beats-agent-serverless-tests

spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: platform-ingest
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: beats-agent-serverless-tests
      description: "Beats serverless tests from elastic-agent repository"
    spec:
      pipeline_file: ".buildkite/serverless.beats.tests.yml"
      maximum_timeout_in_minutes: 180
      provider_settings:
        trigger_mode: none # don't trigger jobs from github activity
      repository: elastic/elastic-agent
      teams:
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        observablt-robots:
          access_level: MANAGE_BUILD_AND_READ  
        # See https://buildkite.com/docs/pipelines/configure/step-types/trigger-step#permissions
        # Otherwise even if merge commits in the main or any branch, they will fail
        everyone:
          access_level: BUILD_AND_READ
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
        SLACK_NOTIFICATIONS_ALL_BRANCHES: "false" # only notify for failures on `main` or \d+.\d+ (release) branches

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: agentless-serverless-release
  description: Initiate agentless serverless release
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/agentless-serverless-release
spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: agentless / serverless / release
      description: Initiate Agentless serverless release
    spec:
      env:
        SLACK_NOTIFICATIONS_CHANNEL: '#agentless-alerts'
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
        SLACK_NOTIFICATIONS_ALL_BRANCHES: "false" # only notify for failures on `main` or \d+.\d+ (release) branches
      default_branch: main
      allow_rebuilds: false
      skip_intermediate_builds: false
      repository: elastic/elastic-agent
      pipeline_file: .buildkite/pipeline.agentless-app-release.yaml
      provider_settings:
        build_branches: false
        build_pull_requests: false
        publish_commit_status: false
        trigger_mode: none
        build_tags: false
        prefix_pull_request_fork_branch_names: false
        skip_pull_request_builds_for_existing_commits: false
      teams:
        agentless-team:
          access_level: MANAGE_BUILD_AND_READ
        cloud-tooling:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
---

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: agentless-tests
  description: Tests the service ntegration in a specific environment
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/agentless-tests
spec:
  type: buildkite-pipeline
  owner: group:ingest-fp
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: agentless-tests
      description: agentless tests
    spec:
      env:
        SLACK_NOTIFICATIONS_CHANNEL: '#agentless-alerts'
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_ON_SUCCESS: "false"
        SLACK_NOTIFICATIONS_ALL_BRANCHES: "false" # only notify for failures on `main` or \d+.\d+ (release) branches
      repository: elastic/elastic-agent
      pipeline_file: .buildkite/pipeline.agentless-tests.yaml
      branch_configuration: "main"
      provider_settings:
        build_pull_requests: false
        trigger_mode: none
      teams:
        agentless-team:
          access_level: MANAGE_BUILD_AND_READ
        cloud-tooling:
          access_level: MANAGE_BUILD_AND_READ
        ingest-fp:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY
