---
- job:
    name: <%= @job_name %>
    display-name: <%= @job_display_name %>
    project-type: freestyle
    description: |
      Rebuild new search indexes with up to date settings and mappings, and reindex all content from the existing indexes.
    logrotate:
      numToKeep: 10
<% if @cron_schedule %>
    triggers:
        - timed: '<%= @cron_schedule %>'
<% end %>
    properties:
      - build-discarder:
          days-to-keep: 30
          artifact-num-to-keep: 5
    builders:
        - shell: ssh deploy@$(govuk_node_list -c search --single-node) "cd /var/apps/<%= @target_application %> && govuk_setenv <%= @target_application %> bundle exec rake search:migrate_schema SEARCH_INDEX=all"
    wrappers:
      - ansicolor:
          colormap: xterm
      - timestamps

---
- job:
    name: <%= @job_name %>
    display-name: <%= @job_display_name %>
    project-type: freestyle
    description: |
      Rebuild new search indexes with up to date settings and mappings, and reindex all content from the existing indexes.
    logrotate:
      numToKeep: 10
<% if @cron_schedule %>
    triggers:
        - timed: '<%= @cron_schedule %>'
<% end %>
    properties:
      - build-discarder:
          days-to-keep: 30
          artifact-num-to-keep: 5
    parameters:
      - choice:
          name: SEARCH_INDEX
          description: The search index to reindex. Defaults to all.
          choices:
              - all
              - detailed
              - government
              - govuk
              - licence-finder
              - metasearch
              - page-traffic
    builders:
        - shell: ssh deploy@$(govuk_node_list -c search --single-node) "cd /var/apps/<%= @target_application %> && govuk_setenv <%= @target_application %> bundle exec rake search:migrate_schema SEARCH_INDEX=\"$SEARCH_INDEX\""
    wrappers:
      - ansicolor:
          colormap: xterm
      - timestamps

Add index selection to Search Reindex job
Add index selection to Search Reindex job

This will allow us to select the index to reindex, which will be faster
than reindexing everything when only one is required.

Also will allow us to remove a section of the developer documentation
where a single index can only be reindexed by running a rake task.
