---
- job:
    name: service-manual_rebuild_search_index
    display-name: service-manual_rebuild_search_index
    project-type: freestyle
    description: "<p>Drops and rebuilds the 'service-manual' search index</p>
      <p><strong>NB</strong> this isn't atomic - the index will be empty for a short while
      (a few seconds, if all goes well). Traffic on this manual is low enough that this isn't a big problem.</p>"
    logrotate:
      artifactNumToKeep: 3
    builders:
        - shell: |
            if [ "$TARGET_APPLICATION" = "designprinciples" ]; then
            ssh deploy@search-1.api.<%= @environment -%> 'cd /var/apps/rummager && RUMMAGER_INDEX=service-manual govuk_setenv rummager bundle exec rake rummager:switch_to_empty_index '
            ssh deploy@frontend-1.frontend.<%= @environment -%> 'cd /var/apps/designprinciples && govuk_setenv designprinciples bundle exec rake rummager:index'
            else
              echo "Not building '$TARGET_APPLICATION'"
            fi
    publishers:
        - trigger:
            project: Smokey
            condition: 'SUCCESS'
    parameters:
        - string:
            name: TARGET_APPLICATION
            description: 'The application that is being deployed'
            default: false

---
- job:
    name: service-manual_rebuild_search_index
    display-name: service-manual_rebuild_search_index
    project-type: freestyle
    description: "<p>Drops and rebuilds the 'service-manual' search index</p>
      <p><strong>NB</strong> this isn't atomic - the index will be empty for a short while
      (a few seconds, if all goes well). Traffic on this manual is low enough that this isn't a big problem.</p>"
    logrotate:
      artifactNumToKeep: 3
    builders:
        - shell: |
            if [ "$TARGET_APPLICATION" = "designprinciples" ]; then
            ssh deploy@search-1.api 'cd /var/apps/rummager && RUMMAGER_INDEX=service-manual govuk_setenv rummager bundle exec rake rummager:switch_to_empty_index '
            ssh deploy@frontend-1.frontend 'cd /var/apps/designprinciples && govuk_setenv designprinciples bundle exec rake rummager:index'
            else
              echo "Not building '$TARGET_APPLICATION'"
            fi
    publishers:
        - trigger:
            project: Smokey
            condition: 'SUCCESS'
    parameters:
        - string:
            name: TARGET_APPLICATION
            description: 'The application that is being deployed'
            default: false

Fix host when rebuilding service-manual index
Fix host when rebuilding service-manual index

search-1.api.<environment> and frontend-1.frontend.<environment> do not require the environment to resolve correctly. In fact, they don't resolve with the environment.
