---
# Legacy CORD documentation verification and publish tasks

- project:
    name: verify-docs-legacy

    jobs:
      - 'verify-documentation-legacy':
          project-regexp: '^(cord|platform-install|cord-tester|rcord|ecord|mcord|opencloud|xos|xos-gui|xos-tosca)$'
          branch-regexp: '{legacy-branches-regexp}'

- project:
    name: publish-docs-legacy

    jobs:
      - 'publish-documentation-legacy':
          project-regexp: '^(cord|platform-install|cord-tester|rcord|ecord|mcord|opencloud|xos|xos-gui|xos-tosca)$'
          branch-regexp: '{legacy-branches-regexp}'

- job-template:
    id: verify-documentation-legacy
    name: "verify-documentation-legacy"

    triggers:
      - cord-infra-gerrit-trigger-patchset:
          gerrit-server-name: '{gerrit-server-name}'
          project-regexp: '{project-regexp}'
          branch-regexp: '{branch-regexp}'
          file-include-regexp: '{doc-files-regexp}'
          dependency-jobs: '{dependency-jobs}'

    properties:
      - cord-infra-properties:
          build-days-to-keep: '{build-days-to-keep}'
          artifact-num-to-keep: '{artifact-num-to-keep}'

    wrappers:
      - lf-infra-wrappers:
          build-timeout: '{build-timeout}'
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

    scm:
      - cord-infra-gerrit-repo-scm:
          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
          branch: '$GERRIT_BRANCH'
          destination-dir: 'cord'

    node: '{build-node}'
    project-type: freestyle
    concurrent: false

    builders:
      - cord-infra-gerrit-repo-patch:
          destination-dir: 'cord'
          project: '$GERRIT_PROJECT'
          change-number: '$GERRIT_CHANGE_NUMBER'
          patchset-number: '$GERRIT_PATCHSET_NUMBER'
      - shell: |
          cd cord/build/docs
          make test

- job-template:
    id: publish-documentation-legacy
    name: 'publish-documentation-legacy'

    triggers:
      - cord-infra-gerrit-trigger-merge:
          gerrit-server-name: '{gerrit-server-name}'
          project-regexp: '{project-regexp}'
          branch-regexp: '{branch-regexp}'
          file-include-regexp: '{doc-files-regexp}'
          dependency-jobs: '{dependency-jobs}'

    properties:
      - cord-infra-properties:
          build-days-to-keep: '{build-days-to-keep}'
          artifact-num-to-keep: '{artifact-num-to-keep}'

    wrappers:
      - lf-infra-wrappers:
          build-timeout: '{build-timeout}'
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

    scm:
      - cord-infra-gerrit-repo-scm:
          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
          branch: '$GERRIT_BRANCH'
          destination-dir: 'cord'

    node: '{build-node}'
    project-type: freestyle
    concurrent: false

    builders:
      - shell: |
          #!/usr/bin/env bash

          # Set up the ssh host keys for the docs host
          mkdir -p ~/.ssh
          echo '{docs-ssh-host-key}' >> ~/.ssh/known_hosts

          # build the docs
          cd cord/docs
          make build

          # copy swagger REST API docs first, then exclude deleting them when copying rest of guide
          rsync -rvzh --delete _book/ {docs-ssh-host}:/var/www/guide/$GERRIT_BRANCH
          rsync -rvzh --delete xos/swagger/ {docs-ssh-host}:/var/www/guide/$GERRIT_BRANCH/swagger

