---
- scm:
    name: smokey_Smokey_Deploy
    scm:
        - git:
            url: git@github.com:alphagov/smokey.git
            branches:
              - main

- job:
    name: Smokey_Deploy
    display-name: Smokey_Deploy
    project-type: freestyle
    properties:
        - build-discarder:
            days-to-keep: 30
            artifact-num-to-keep: 5
        - github:
            url: https://github.com/alphagov/smokey/
    scm:
      - smokey_Smokey_Deploy
    builders:
        - shell: |
            export DEPLOY_TO=$(govuk_node_list -c monitoring)
            sh -x deploy.sh
    triggers:
        - timed: |
            TZ=Europe/London
            H 9 * * *

---
- scm:
    name: smokey_Smokey_Deploy
    scm:
        - git:
            url: git@github.com:alphagov/smokey.git
            branches:
              - main

- job:
    name: Smokey_Deploy
    display-name: Smokey_Deploy
    project-type: freestyle
    properties:
        - build-discarder:
            days-to-keep: 30
            artifact-num-to-keep: 5
        - github:
            url: https://github.com/alphagov/smokey/
    scm:
      - smokey_Smokey_Deploy
    builders:
        - shell: |
            export DEPLOY_TO=$(govuk_node_list -c monitoring)
            sh -x deploy.sh
            # Deploy to downstream environment using same credentials as Deploy_App_Downstream job
            CRUMB=$(curl https://<%= @jenkins_downstream_api_user %>:<%= @jenkins_downstream_api_password %>@<%= @deploy_url %>/crumbIssuer/api/json | jq --raw-output '. | .crumb')
            curl -f -H "Jenkins-Crumb:$CRUMB" -XPOST https://<%= @jenkins_downstream_api_user %>:<%= @jenkins_downstream_api_password %>@<%= @deploy_url %>/job/Smokey_Deploy/build"
    triggers:
        - timed: |
            TZ=Europe/London
            H 9 * * *

Add downstream deploy steps to Smokey_Deploy job
Add downstream deploy steps to Smokey_Deploy job

This is inspired by the Deploy_App_Downstream job and uses the same
credentials when deploying smokey downstream.
