##########################################################
resource_types:
- name: s3-multi
  type: docker-image
  source:
    repository: kdvolder/s3-resource-simple
- name: slack-notification
  type: docker-image
  source:
    repository: cfcommunity/slack-notification-resource
    tag: latest
- name: artifactory-resource
  type: docker-image
  source:
    repository: springio/artifactory-resource
    tag: 0.0.10
#########################################################
resources:
- name: monthly
  type: time
  check_every: 24h
  source:
    interval: 720h
# - name: every-minute
#   type: time
#   check_every: 1m
#   source:
#     interval: 1m
- name: docker-git
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    branch: ((branch))
    private_key: ((rsa_id))
    paths:
    - concourse/docker
- name: sts4
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    branch: ((branch))
    private_key: ((rsa_id))
- name: sts4-out
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    branch: ((branch))
    private_key: ((rsa_id))
# - name: sts4-wiki
#   type: git
#   source:
#     uri: git@github.com:spring-projects/sts4.wiki.git
#     branch: master
#     private_key: ((rsa_id))
- name: mirror-vscode-spring-boot
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:pivotal/sts4-vscode-spring-boot-mirror.git
- name: mirror-vscode-concourse
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:pivotal/sts4-vscode-concourse-mirror.git
- name: mirror-vscode-bosh
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:pivotal/sts4-vscode-bosh-mirror.git
- name: atom-cf-manifest-yaml
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:spring-projects/atom-cf-manifest-yaml.git
- name: atom-concourse
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:spring-projects/atom-concourse.git
- name: atom-bosh
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:spring-projects/atom-bosh.git
- name: atom-spring-boot
  type: git
  source:
    branch: ((branch))
    private_key: ((rsa_id))
    uri: git@github.com:spring-projects/atom-spring-boot.git
- name: jvm-launch-utils-git
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    private_key: ((rsa_id))
    branch: ((branch))
    paths:
    - nodejs-packages/jvm-launch-utils
- name: tasks
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    branch: ((branch))
    paths:
    - concourse/tasks
    private_key: ((rsa_id))
- name: s3-headless-maven-out
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/snapshots/headless-maven-out-(.*).tar.gz
- name: s3-concourse-vsix-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/vscode-extensions/snapshots/vscode-concourse-(.*).vsix
- name: s3-bosh-vsix-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/vscode-extensions/snapshots/vscode-bosh-(.*).vsix
- name: s3-manifest-yaml-vsix-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/vscode-extensions/snapshots/vscode-manifest-yaml-(.*).vsix
- name: s3-spring-boot-vsix-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/vscode-extensions/snapshots/vscode-spring-boot-(.*).vsix
- name: s3-concourse-vsix-release
  type: s3
  source:
    bucket: dist.springsource.com
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    regexp: release/STS4/vscode/vscode-concourse-(.*).vsix
- name: s3-bosh-vsix-release
  type: s3
  source:
    bucket: dist.springsource.com
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    regexp: release/STS4/vscode/vscode-bosh-(.*).vsix
- name: s3-manifest-yaml-vsix-release
  type: s3
  source:
    bucket: dist.springsource.com
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    regexp: release/STS4/vscode/vscode-manifest-yaml-(.*).vsix
- name: s3-spring-boot-vsix-release
  type: s3
  source:
    bucket: dist.springsource.com
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    #region_name: ((s3_region))
    regexp: release/STS4/vscode/vscode-spring-boot-(.*).vsix
- name: s3-manifest-yaml-fatjar-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/fatjars/snapshots/manifest-yaml-language-server-(.*).jar
- name: s3-manifest-yaml-fatjar--rc
  type: s3
  source:
    bucket: ((s3_prod_bucket))
    access_key_id: ((s3_prod_accesskey))
    secret_access_key: ((s3_prod_secretkey))
    region_name: ((s3_prod_region))
    regexp: release/STS4/fatjars/manifest-yaml-language-server-(.*).jar
- name: s3-concourse-fatjar-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/fatjars/snapshots/concourse-language-server-(.*).jar
- name: s3-concourse-fatjar--rc
  type: s3
  source:
    bucket: ((s3_prod_bucket))
    access_key_id: ((s3_prod_accesskey))
    secret_access_key: ((s3_prod_secretkey))
    region_name: ((s3_prod_region))
    regexp: release/STS4/fatjars/concourse-language-server-(.*).jar
- name: s3-bosh-fatjar-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/fatjars/snapshots/bosh-language-server-(.*).jar
- name: s3-bosh-fatjar--rc
  type: s3
  source:
    bucket: ((s3_prod_bucket))
    access_key_id: ((s3_prod_accesskey))
    secret_access_key: ((s3_prod_secretkey))
    region_name: ((s3_prod_region))
    regexp: release/STS4/fatjars/bosh-language-server-(.*).jar
- name: s3-spring-boot-fatjar-snapshot
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: sts4/fatjars/snapshots/spring-boot-language-server-(.*).jar
- name: s3-spring-boot-fatjar--rc
  type: s3
  source:
    bucket: ((s3_prod_bucket))
    access_key_id: ((s3_prod_accesskey))
    secret_access_key: ((s3_prod_secretkey))
    region_name: ((s3_prod_region))
    regexp: release/STS4/fatjars/spring-boot-language-server-(.*).jar
- name: vscode-snapshot-website
  type: s3-multi
  source:
    bucket: ((s3_prod_bucket))
    access_key_id: ((s3_prod_accesskey))
    secret_access_key: ((s3_prod_secretkey))
    region_name: ((s3_region))
    path: snapshot/STS4/vscode-extensions
    options:
    - "--acl public-read"
# - name: atom-snapshot-website
#   type: s3-multi
#   source:
#     bucket: ((s3_prod_bucket))
#     access_key_id: ((s3_prod_accesskey))
#     secret_access_key: ((s3_prod_secretkey))
#     region_name: ((s3_region))
#     path: snapshot/STS4/atom-packages
#     options:
#     - "--acl public-read"
- name: slack-notification
  type: slack-notification
  source:
    url: ((slack_webhook))
- name: docker-image
  type: docker-image
  source:
    username: ((docker_hub_username))
    password: ((docker_hub_password))
    repository: kdvolder/sts4-build-env
- name: theia-docker-image
  type: docker-image
  source:
    username: ((docker_hub_username))
    password: ((docker_hub_password))
    repository: kdvolder/sts4-theia-snapshot
- name: maven-cache
  type: s3
  source:
    bucket: ((s3_bucket))
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    regexp: mvn-caches/sts4-(.*).tar.gz
- name: version
  type: semver
  source:
    driver: s3
    bucket: ((s3_bucket))
    key: versions/vscode-extensions
    access_key_id: ((s3_accesskey))
    secret_access_key: ((s3_secretkey))
    region_name: ((s3_region))
    initial_version: 0.0.5-RC.6
- name: artifactory
  type: artifactory-resource
  source:
    uri: "https://repo.spring.io"
    username: ((artifactory_user))
    password: ((artifactory_password))
    build_name: spring-tools-4
########################################################################################
jobs:
- name: vsix-s3-publish
  plan:
  - in_parallel:
    - get: s3-spring-boot-vsix-snapshot
    - get: s3-manifest-yaml-vsix-snapshot
    - get: s3-bosh-vsix-snapshot
    - get: s3-concourse-vsix-snapshot
  - in_parallel:
    - put: s3-spring-boot-vsix-release
      params:
        file: s3-spring-boot-vsix-snapshot/*.vsix
        acl: public-read
    - put: s3-manifest-yaml-vsix-release
      params:
        file: s3-manifest-yaml-vsix-snapshot/*.vsix
        acl: public-read
    - put: s3-bosh-vsix-release
      params:
        file: s3-bosh-vsix-snapshot/*.vsix
        acl: public-read
    - put: s3-concourse-vsix-release
      params:
        file: s3-concourse-vsix-snapshot/*.vsix
        acl: public-read
# Stuff below is untested and incomplete
# - name: create-release-wiki-page
#   plan:
#   - in_parallel:
#     - get: sts4-wiki
#     - get: sts4
#     - get: s3-spring-boot-vsix-release
#     - get: s3-manifest-yaml-vsix-release
#     - get: s3-bosh-vsix-release
#     - get: s3-concourse-vsix-release
#   - task: create-vsix-release-wiki-page
#     file: sts4/concourse/tasks/create-release-wiki-page.yml
#   - put: sts4-wiki
#     params:
#       rebase: true
#       repository: sts4-wiki-out
- name: build-theia-docker-snapshot-image
  serial: true
  on_failure:
    put: slack-notification
    params:
      text: |
          Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
          https://ci.spring.io/teams/tools/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}
  plan:
  - in_parallel:
    - get: s3-concourse-vsix-snapshot
      trigger: true
      passed:
      - build-consourse-vsix-snapshot
    - get: s3-spring-boot-vsix-snapshot
      trigger: true
      passed:
      - build-spring-boot-vsix-snapshot
    - get: s3-bosh-vsix-snapshot
      trigger: true
      passed:
      - build-bosh-vsix-snapshot
    - get: s3-manifest-yaml-vsix-snapshot
      trigger: true
      passed:
      - build-manifest-yaml-vsix-snapshot
    - get: sts4
  - task: prepare-theia-docker-image
    file: sts4/concourse/tasks/prepare-theia-docker-image.yml
  - put: theia-docker-image
    params:
      build: output
    get_params:
      skip_download: true
- name: build-docker-image
  serial: true
  plan:
  - get: monthly
    trigger: true
  - get: docker-git
    trigger: true
  - put: docker-image
    params:
      build: docker-git/concourse/docker
    get_params: 
      skip_download: true
- name: build-mvn-cache
  serial: true
  plan:
  - get: sts4
    trigger: true
  - task: build-mvn-cache
    file: sts4/concourse/tasks/build-mvn-cache.yml
  - put: maven-cache
    params:
      file: out/*.tar.gz
- name: build-consourse-vsix-snapshot
  plan:
  - in_parallel:
    - get: sts4
      trigger: true
    - get: maven-cache
  - task: build-consourse-vsix-snapshot
    file: sts4/concourse/tasks/build-vsix.yml
    params:
      extension_id: vscode-concourse
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
  - in_parallel:
    - put: s3-concourse-vsix-snapshot
      params: 
        file: out/vscode-concourse-*.vsix
        acl: public-read
    - put: mirror-vscode-concourse
      params:
        repository: sts4
- name: build-bosh-vsix-snapshot
  plan:
  - in_parallel:
    - get: sts4
      trigger: true
    - get: maven-cache
  - task: build-bosh-vsix-snapshot
    file: sts4/concourse/tasks/build-vsix.yml
    params:
      extension_id: vscode-bosh
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
  - in_parallel:
    - put: s3-bosh-vsix-snapshot
      params: 
        file: out/vscode-bosh-*.vsix
        acl: public-read
    - put: mirror-vscode-bosh
      params:
        repository: sts4
- name: build-manifest-yaml-vsix-snapshot
  plan:
  - in_parallel:
    - get: sts4
      trigger: true
    - get: maven-cache
  - task: build-manifest-yaml-vsix-snapshot
    file: sts4/concourse/tasks/build-vsix.yml
    params:
      extension_id: vscode-manifest-yaml
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
  - in_parallel:
    - put: s3-manifest-yaml-vsix-snapshot
      params: 
        file: out/vscode-manifest-yaml-*.vsix
        acl: public-read
- name: build-spring-boot-vsix-snapshot
  plan:
  - in_parallel:
    - get: sts4
      trigger: true
    - get: maven-cache
  - task: build-spring-boot-vsix-snapshot
    file: sts4/concourse/tasks/build-vsix.yml
    params:
      extension_id: vscode-spring-boot
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
  - in_parallel:
    - put: s3-spring-boot-vsix-snapshot
      params: 
        file: out/vscode-spring-boot-*.vsix
        acl: public-read
    - put: mirror-vscode-spring-boot
      params:
        repository: sts4
- name: trigger-rc-build
  serial: true
  plan: 
  - in_parallel:
    - get: sts4
      passed:
      - build-manifest-yaml-vsix-snapshot
      - build-consourse-vsix-snapshot
      - build-bosh-vsix-snapshot
      - build-spring-boot-vsix-snapshot
    - do:
      - get: version
        params:
          pre: RC
      - put: version
        params:
          file: version/version
  - put: sts4-out
    params:
      repository: sts4
      only_tag: true
      tag_prefix: V_
      tag: version/version
- name: promote-fatjars-to-rc
  serial: true
  plan:
  - in_parallel:
    - get: s3-bosh-fatjar-snapshot
      passed:
      - build-bosh-atom-package
    - get: s3-concourse-fatjar-snapshot
      passed:
      - build-concourse-atom-package
    - get: s3-manifest-yaml-fatjar-snapshot
      passed:
      - build-manifest-yaml-atom-package
    - get: s3-spring-boot-fatjar-snapshot
      passed:
      - build-spring-boot-atom-package
  - in_parallel:
    - put: s3-bosh-fatjar--rc
      params:
        file: s3-bosh-fatjar-snapshot/*.jar
        acl: public-read
    - put: s3-concourse-fatjar--rc
      params:
        file: s3-concourse-fatjar-snapshot/*.jar
        acl: public-read
    - put: s3-manifest-yaml-fatjar--rc
      params:
        file: s3-manifest-yaml-fatjar-snapshot/*.jar
        acl: public-read
    - put: s3-spring-boot-fatjar--rc
      params:
        file: s3-spring-boot-fatjar-snapshot/*.jar
        acl: public-read
- name: prepare-manifest-yaml-atom-rc
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: atom-cf-manifest-yaml
    - get: s3-manifest-yaml-fatjar--rc
      trigger: true
      passed:
      - promote-fatjars-to-rc
  - task: build-atom-package
    params:
      package_name: atom-cf-manifest-yaml
    input_mapping:
      release_repo: atom-cf-manifest-yaml
      fatjar: s3-manifest-yaml-fatjar--rc
    file: sts4/concourse/tasks/build-atom-package.yml
  - put: atom-cf-manifest-yaml
    params:
      repository: out/repo
      rebase: true
- name: prepare-concourse-atom-rc
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: atom-concourse
    - get: s3-concourse-fatjar--rc
      trigger: true
      passed:
      - promote-fatjars-to-rc
  - task: build-atom-package
    params:
      package_name: atom-concourse
    input_mapping:
      release_repo: atom-concourse
      fatjar: s3-concourse-fatjar--rc
    file: sts4/concourse/tasks/build-atom-package.yml
  - put: atom-concourse
    params:
      repository: out/repo
      rebase: true
- name: prepare-bosh-atom-rc
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: atom-bosh
    - get: s3-bosh-fatjar--rc
      trigger: true
      passed:
      - promote-fatjars-to-rc
  - task: build-atom-package
    params:
      package_name: atom-bosh
    input_mapping:
      release_repo: atom-bosh
      fatjar: s3-bosh-fatjar--rc
    file: sts4/concourse/tasks/build-atom-package.yml
  - put: atom-bosh
    params:
      repository: out/repo
      rebase: true
- name: prepare-spring-boot-atom-rc
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: atom-spring-boot
    - get: s3-spring-boot-fatjar--rc
      trigger: true
      passed:
      - promote-fatjars-to-rc
  - task: build-atom-package
    params:
      package_name: atom-spring-boot
    input_mapping:
      release_repo: atom-spring-boot
      fatjar: s3-spring-boot-fatjar--rc
    file: sts4/concourse/tasks/build-atom-package.yml
  - put: atom-spring-boot
    params:
      repository: out/repo
      rebase: true
- name: tag-atom-release
  plan:
  - in_parallel:
    - get: sts4
    - get: atom-bosh
      passed:
      - prepare-bosh-atom-rc
    - get: atom-concourse
      passed:
      - prepare-concourse-atom-rc
    # - get: atom-spring-boot
    #   passed:
    #   - prepare-spring-boot-atom-rc
    - get: atom-cf-manifest-yaml
      passed:
      - prepare-manifest-yaml-atom-rc
  - task: tag-atom-releases
    file: sts4/concourse/tasks/tag-atom-releases.yml
  - in_parallel:
    - put: atom-bosh
      params:
        repository: out/atom-bosh
        only_tag: true
    - put: atom-concourse
      params:
        repository: out/atom-concourse
        only_tag: true
    # - put: atom-spring-boot
    #   params:
    #     repository: out/atom-spring-boot
    #     only_tag: true
    - put: atom-cf-manifest-yaml
      params:
        repository: out/atom-cf-manifest-yaml
        only_tag: true
- name: publish-atom-releases
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: atom-concourse
      trigger: true
      passed:
      - tag-atom-release
    - get: atom-bosh
      trigger: true
      passed:
      - tag-atom-release
    - get: atom-cf-manifest-yaml
      trigger: true
      passed:
      - tag-atom-release
    # - get: atom-spring-boot
    #   trigger: true
    #   passed:
    #   - tag-atom-release
  - task: publish-atom-releases
    file: sts4/concourse/tasks/publish-atom-releases.yml
    params:
      atom_token: ((atom_token))
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text: |
          STS 4 Atom Extensions released
          Releases now available on Atom Marketplace:
           • <https://atom.io/packages/concourse-pipeline-yaml|Concourse CI Pipeline Editor>
           • <https://atom.io/packages/bosh-yaml|Bosh YAML Editor>
           • <https://atom.io/packages/cf-manifest-yaml|CF Manifest YAML Editor>
          #  • <https://atom.io/packages/spring-boot|Spring Boot Support>

- name: build-concourse-rc
  plan:
  - in_parallel:
    - get: maven-cache
      passed:
      - build-consourse-vsix-snapshot
    - get: sts4
      passed: 
      - trigger-rc-build
    - get: version
      trigger: true
      passed: 
      - trigger-rc-build
  - task: build-concourse-rc
    file: sts4/concourse/tasks/rc-build.yml
    params:
      extension_id: vscode-concourse
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
  - put: s3-concourse-vsix-snapshot
    params: 
      file: out/vscode-concourse-*.vsix
      acl: public-read
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text_file: s3-concourse-vsix-snapshot/url
        icon_url: https://raw.githubusercontent.com/spring-projects/sts4/master/vscode-extensions/vscode-concourse/icon.png
        text: |
          Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has succeed!
          Release candidate available for testing $TEXT_FILE_CONTENT
- name: build-manifest-yaml-rc
  plan:
  - in_parallel:
    - get: maven-cache
      passed:
      - build-manifest-yaml-vsix-snapshot
    - get: sts4
      passed: 
      - trigger-rc-build
    - get: version
      trigger: true
      passed: 
      - trigger-rc-build
  - task: build-manifest-yaml-rc
    file: sts4/concourse/tasks/rc-build.yml
    params:
      extension_id: vscode-manifest-yaml
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
  - put: s3-manifest-yaml-vsix-snapshot
    params: 
      file: out/vscode-manifest-yaml-*.vsix
      acl: public-read
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text_file: s3-manifest-yaml-vsix-snapshot/url
        icon_url: https://raw.githubusercontent.com/spring-projects/sts4/master/vscode-extensions/vscode-manifest-yaml/icon.png
        text: |
          Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has succeed!
          Release candidate available for testing $TEXT_FILE_CONTENT
- name: build-bosh-rc
  plan:
  - in_parallel:
    - get: maven-cache
      passed:
      - build-bosh-vsix-snapshot
    - get: sts4
      passed: 
      - trigger-rc-build
    - get: version
      trigger: true
      passed: 
      - trigger-rc-build
  - task: build-bosh-rc
    file: sts4/concourse/tasks/rc-build.yml
    params:
      extension_id: vscode-bosh
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
  - put: s3-bosh-vsix-snapshot
    params: 
      file: out/vscode-*.vsix
      acl: public-read
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text_file: s3-bosh-vsix-snapshot/url
        icon_url: https://raw.githubusercontent.com/spring-projects/sts4/master/vscode-extensions/vscode-concourse/icon.png
        text: |
          Build ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has succeed!
          Release candidate available for testing $TEXT_FILE_CONTENT
- name: build-spring-boot-rc
  plan:
  - in_parallel:
    - get: maven-cache
      passed:
      - build-spring-boot-vsix-snapshot
    - get: sts4
      passed: 
      - trigger-rc-build
    - get: version
      trigger: true
      passed: 
      - trigger-rc-build
  - task: build-spring-boot-rc
    attempts: 4
    file: sts4/concourse/tasks/rc-build.yml
    params:
      extension_id: vscode-spring-boot
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
  - put: s3-spring-boot-vsix-snapshot
    params: 
      file: out/vscode-*.vsix
      acl: public-read
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text_file: s3-spring-boot-vsix-snapshot/url
        icon_url: https://raw.githubusercontent.com/spring-projects/sts4/master/vscode-extensions/vscode-spring-boot/spring-boot-logo.png
        text: |
          Build ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has succeed!
          Release candidate available for testing $TEXT_FILE_CONTENT
- name: publish-release
  serial: true
  plan:
  - in_parallel:
    - get: tasks
    - get: sts4
      passed:
      - build-manifest-yaml-rc
      - build-concourse-rc
      - build-bosh-rc
      - build-spring-boot-rc
    - get: version
      passed:
      - build-concourse-rc
      - build-manifest-yaml-rc
      - build-bosh-rc
      - build-spring-boot-rc
      params:
        bump: final
    - get: s3-concourse-vsix-snapshot
      passed:
      - build-concourse-rc
    - get: s3-manifest-yaml-vsix-snapshot
      passed:
      - build-manifest-yaml-rc
    - get: s3-bosh-vsix-snapshot
      passed:
      - build-bosh-rc
    - get: s3-spring-boot-vsix-snapshot
      passed:
      - build-spring-boot-rc
  - task: publish-vsix-releases
    file: tasks/concourse/tasks/publish-vsix-releases.yml
    input_mapping:
      sts4: tasks
    params:
      vsce_token: ((vsce_token))
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text_file: version/version
        text: |
          STS 4 VScode Extensions $TEXT_FILE_CONTENT released
          Releases now available on Vscode Marketplace:
           • <https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-manifest-yaml|Cloudfoundry Manifest Editor>
           • <https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-concourse|Concourse CI Pipeline Editor>
           • <https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-bosh|Bosh Deployment Manifest Editor>
           • <https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-spring-boot|Spring Boot Support>
  - in_parallel:
    - put: sts4-out
      params:
        repository: sts4
        only_tag: true
        tag: version/version
        tag_prefix: V_
    - put: version
      params:
        file: version/version
- name: publish-concourse-vsix-release
  serial: true
  plan:
  - in_parallel:
    - get: tasks
    - get: sts4
      passed:
      - build-concourse-rc
    - get: version
      passed:
      - build-concourse-rc
      params:
        bump: final
    - get: s3-concourse-vsix-snapshot
      passed:
      - build-concourse-rc
  - task: publish-release
    file: tasks/concourse/tasks/publish-concourse-vsix-release.yml
    input_mapping:
      sts4: tasks
    params:
      vsce_token: ((vsce_token))
    on_failure:
      put: slack-notification
      params:
        text: |
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!      
    on_success:
      put: slack-notification
      params:
        channel: "#tools-team-internal"
        text_file: version/version
        text: |
          STS 4 VScode Extensions $TEXT_FILE_CONTENT released
          Releases now available on Vscode Marketplace:
           • <https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-concourse|Concourse CI Pipeline Editor>
  - in_parallel:
    - put: sts4-out
      params:
        repository: sts4
        only_tag: true
        tag: version/version
        tag_prefix: V_
    - put: version
      params:
        file: version/version
- name: bump-version-patch
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: version
      params:
        bump: patch
  - task: bump-versions
    file: sts4/concourse/tasks/bump-versions.yml
  - put: sts4
    params:
      repository: out
      rebase: true
  - put: version
    params:
      file: version/version
- name: bump-version-minor
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: version
      params:
        bump: minor
  - task: bump-versions
    file: sts4/concourse/tasks/bump-versions.yml
  - put: sts4
    params:
      repository: out
      rebase: true
  - put: version
    params:
      file: version/version
- name: bump-version-major
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: version
      params:
        bump: major
  - task: bump-versions
    file: sts4/concourse/tasks/bump-versions.yml
  - put: sts4
    params:
      repository: out
      rebase: true
  - put: version
    params:
      file: version/version
- name: build-vscode-snapshot-website
  serial: true
  plan:
  - in_parallel:
    - get: sts4
    - get: s3-bosh-vsix-snapshot
      trigger: true
      passed:
      - build-bosh-vsix-snapshot
    - get: s3-manifest-yaml-vsix-snapshot
      trigger: true
      passed:
      - build-manifest-yaml-vsix-snapshot
    - get: s3-spring-boot-vsix-snapshot
      trigger: true
      passed:
      - build-spring-boot-vsix-snapshot
    - get: s3-concourse-vsix-snapshot
      trigger: true
      passed:
      - build-consourse-vsix-snapshot
  - task: build-website
    file: sts4/concourse/tasks/build-vscode-website.yml
  - put: vscode-snapshot-website
    params:
      path: website
- name: build-fatjars
  plan:
  - in_parallel:
    - get: sts4
      trigger: true
    - get: maven-cache
  - task: build-fatjars
    file: sts4/concourse/tasks/atom-language-servers-test.yml
    attempts: 3
    on_failure:
      put: slack-notification
      params:
        text: |
          Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
    on_success:
      in_parallel:
      - put: s3-headless-maven-out
        params:
          file: out/headless-maven-out-*.tar.gz
      - put: s3-manifest-yaml-fatjar-snapshot
        params:
          file: out/manifest-yaml-language-server-*.jar
          acl: public-read
      - put: s3-concourse-fatjar-snapshot
        params:
          file: out/concourse-language-server-*.jar
          acl: public-read
      - put: s3-bosh-fatjar-snapshot
        params:
          file: out/bosh-language-server-*.jar
          acl: public-read
      - put: s3-spring-boot-fatjar-snapshot
        params:
          file: out/spring-boot-language-server-*.jar
          acl: public-read
      - put: artifactory
        params:
          debug: true
          disable_checksum_uploads: true
          build_uri: "https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_ID}"
          build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}"
          repo: libs-snapshot-local
          folder: maven-out
          exclude: 
          - "**/_remote.repositories"
# - name: publish-headless-snapshots
#   plan:
#   - in_parallel:
#     - get: s3-headless-maven-out
#       passed:
#       - build-fatjars
#     - get: sts4
#   - task: unpack
#     file: sts4/concourse/tasks/unpack.yml
#     input_mapping:
#       in: s3-headless-maven-out
#   - put: artifactory
#     params:
#       debug: true
#       disable_checksum_uploads: true
#       build_uri: "https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_ID}"
#       build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}"
#       repo: libs-snapshot-local
#       folder: out
#       exclude: 
#       - "**/_remote.repositories"
#       #Can't publish org.json jar because its got a 'release' version number, and artifactory rejects publishing it in snapshot repo.
#       - "**/org.json*"
- name: build-manifest-yaml-atom-package
  serial: true
  plan:
  - in_parallel:
    - get: sts4
      passed:
      - build-fatjars
    - get: atom-cf-manifest-yaml
    - get: s3-manifest-yaml-fatjar-snapshot
      trigger: true
      passed:
      - build-fatjars
  
  - task: build-manifest-yaml-atom-package
    params:
      package_name: atom-cf-manifest-yaml
    input_mapping:
      release_repo: atom-cf-manifest-yaml
      fatjar: s3-manifest-yaml-fatjar-snapshot
    file: sts4/concourse/tasks/build-atom-package.yml
  - in_parallel:
    - put: atom-cf-manifest-yaml
      params:
        repository: out/repo
        rebase: true    
  on_failure:
    put: slack-notification
    params:
      text: |
         Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: build-concourse-atom-package
  serial: true
  plan:
  - in_parallel:
    - get: sts4
      passed:
      - build-fatjars
  
    - get: atom-concourse
    - get: s3-concourse-fatjar-snapshot
      trigger: true
      passed:
      - build-fatjars
  
  - task: build-concourse-pipeline-yaml-atom-package
    params:
      package_name: atom-concourse
    input_mapping:
      release_repo: atom-concourse
      fatjar: s3-concourse-fatjar-snapshot
    file: sts4/concourse/tasks/build-atom-package.yml
  - in_parallel:
    - put: atom-concourse
      params:
        repository: out/repo
        rebase: true    
  on_failure:
    put: slack-notification
    params:
      text: |
         Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: build-bosh-atom-package
  serial: true
  plan:
  - in_parallel:
    - get: sts4
      passed:
      - build-fatjars
  
    - get: atom-bosh
    - get: s3-bosh-fatjar-snapshot
      trigger: true
      passed:
      - build-fatjars
  
  - task: build-bosh-atom-package
    params:
      package_name: atom-bosh
    input_mapping:
      fatjar: s3-bosh-fatjar-snapshot
      release_repo: atom-bosh
    file: sts4/concourse/tasks/build-atom-package.yml
  - in_parallel:
    - put: atom-bosh
      params:
        repository: out/repo
        rebase: true    
  on_failure:
    put: slack-notification
    params:
      text: |
         Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: build-spring-boot-atom-package
  serial: true
  plan:
  - in_parallel:
    - get: sts4
      passed:
      - build-fatjars
  
    - get: atom-spring-boot
    - get: s3-spring-boot-fatjar-snapshot
      trigger: true
      passed:
      - build-fatjars
  
  - task: build-spring-boot-atom-package
    params:
      package_name: atom-spring-boot
    input_mapping:
      fatjar: s3-spring-boot-fatjar-snapshot
      release_repo: atom-spring-boot
    file: sts4/concourse/tasks/build-atom-package.yml
  - in_parallel:
    - put: atom-spring-boot
      params:
        repository: out/repo
        rebase: true    
  on_failure:
    put: slack-notification
    params:
      text: |
         Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: publish-jvm-launch-utils
  plan:
  - in_parallel:
    - get: jvm-launch-utils-git
      trigger: true
    - get: tasks 
  - task: publish
    file: tasks/concourse/tasks/npm-publish.yml
    input_mapping:
      sources_repo: jvm-launch-utils-git
    params:
      npm_token: ((npm_token))
      sources_dir: nodejs-packages/jvm-launch-utils
groups:
- name: vscode-snapshot
  jobs:
  - build-vscode-snapshot-website
  - build-consourse-vsix-snapshot
  - build-spring-boot-vsix-snapshot
  - build-bosh-vsix-snapshot
  - build-manifest-yaml-vsix-snapshot
- name: vscode-release
  jobs:
  - build-bosh-rc
  - build-concourse-rc
  - build-manifest-yaml-rc
  - build-spring-boot-rc
  - trigger-rc-build
  - publish-release
  - build-manifest-yaml-vsix-snapshot
  - build-consourse-vsix-snapshot
  - build-bosh-vsix-snapshot
  - build-spring-boot-vsix-snapshot
  - publish-concourse-vsix-release
- name: bump-versions
  jobs:
  - bump-version-patch
  - bump-version-minor
  - bump-version-major
- name: atom-snapshots
  jobs:
  # - build-atom-snapshot-website
  - build-fatjars
  - build-concourse-atom-package
  - build-bosh-atom-package
  - build-manifest-yaml-atom-package
  - build-spring-boot-atom-package
- name: atom-release
  jobs:
  - build-fatjars
  - build-concourse-atom-package
  - build-bosh-atom-package
  - build-manifest-yaml-atom-package
  - build-spring-boot-atom-package
  - prepare-bosh-atom-rc
  - prepare-concourse-atom-rc
  - prepare-manifest-yaml-atom-rc
  - prepare-spring-boot-atom-rc
  - promote-fatjars-to-rc
  - tag-atom-release
  - publish-atom-releases
- name: theia-snapshots
  jobs:
  - build-theia-docker-snapshot-image
  - build-consourse-vsix-snapshot
  - build-manifest-yaml-vsix-snapshot
  - build-spring-boot-vsix-snapshot
  - build-bosh-vsix-snapshot
- name: setup
  jobs:
  - build-mvn-cache
  - build-docker-image
- name: artifactory
  jobs:
  - build-fatjars
#  - publish-headless-snapshots
# - name: debugging
#   jobs:
#   - concourse-ls-tests
- name: npm-packages
  jobs:
  - publish-jvm-launch-utils
- name: experimental
  jobs: 
  - vsix-s3-publish
#  - create-release-wiki-page
