[INF-146]

Unify mechanism across multiple ci-management repos

- move converted per-repo jobs into the jjb/repos hierarchy

- Pull in macros (with onf- prefix) and common scripts from ONOS/Aether
  ci-management repos, unifying behavior

- Update tagging scripts to unify changes

- Update gerrit repo multi-checkout and patch script

- Change over to newer static host for publishing charts/docs

- use python3 venv instead of virtualenv

Change-Id: Id46fdc23679b8854c54e294a7fb022e69d6d28f9
diff --git a/jjb/templates/helm-lint.yaml b/jjb/templates/helm-lint.yaml
new file mode 100644
index 0000000..215c790
--- /dev/null
+++ b/jjb/templates/helm-lint.yaml
@@ -0,0 +1,49 @@
+---
+# SPDX-FileCopyrightText: 2020-2022 Open Networking Foundation <info@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+# check helm charts with `helm lint --strict` and that charts version is
+# updated when the contents of a chart is modified.
+
+- job-template:
+    id: helm-lint
+    name: 'helm-lint_{project}'
+    description: |
+      Created by helm-lint job-template from ci-management/jjb/templates/helm-lint.yaml
+
+    triggers:
+      - onf-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project}'
+          branch-regexp: '{all-branches-regexp}'
+          file-include-regexp: '{all-files-regexp}'
+          dependency-jobs: ''
+
+    properties:
+      - onf-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:
+      - onf-infra-gerrit-scm:
+          git-url: '{gerrit-server-ssh-url}/$GERRIT_PROJECT'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-disable: '{submodule-disable}'
+          submodule-recursive: 'false'
+          submodule-timeout: '{submodule-timeout}'
+          choosing-strategy: gerrit
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          basedir: ''
+
+    node: 'ubuntu18.04-basebuild-2c-4g'
+    project-type: freestyle
+    concurrent: true
+
+    builders:
+      - shell: !include-raw-escape: jjb/shell/helm-lint.sh
diff --git a/jjb/templates/publish-helm-repo.yaml b/jjb/templates/publish-helm-repo.yaml
new file mode 100644
index 0000000..226a0d3
--- /dev/null
+++ b/jjb/templates/publish-helm-repo.yaml
@@ -0,0 +1,49 @@
+---
+# SPDX-FileCopyrightText: 2020 Open Networking Foundation <info@opennetworking.org>
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+- job-template:
+    id: publish-helm-repo
+    name: 'publish-helm-repo_{project}'
+    description: |
+      Created by publish-helm-repo job-template from
+      ci-management/jjb/templates/publish-helm-repo.yaml
+    disabled: '{disable-job}'
+
+    triggers:
+      - onf-infra-gerrit-trigger-merge:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project}'
+          branch-regexp: '{all-branches-regexp}'
+          file-include-regexp: '{all-files-regexp}'
+          dependency-jobs: ''
+
+    properties:
+      - onf-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - onf-infra-rsync-wrappers:
+          build-timeout: '{build-timeout}'
+          ssh_credential_list:
+            - 'new-cord-jenkins-ssh'
+
+    scm:
+      - onf-infra-gerrit-scm:
+          git-url: '{gerrit-server-ssh-url}/$GERRIT_PROJECT'
+          refspec: ''
+          branch: '$GERRIT_BRANCH'
+          submodule-disable: '{submodule-disable}'
+          submodule-recursive: 'false'
+          submodule-timeout: '{submodule-timeout}'
+          choosing-strategy: gerrit
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          basedir: ''
+
+    node: 'ubuntu18.04-basebuild-2c-4g'
+    project-type: freestyle
+    concurrent: false
+
+    builders:
+      - shell: !include-raw-escape: jjb/shell/publish-helm-repo.sh
diff --git a/jjb/templates/sync-dir.yaml b/jjb/templates/sync-dir.yaml
index 5f273fc..699d0c1 100644
--- a/jjb/templates/sync-dir.yaml
+++ b/jjb/templates/sync-dir.yaml
@@ -1,4 +1,7 @@
 ---
+# SPDX-FileCopyrightText: 2020 Open Networking Foundation <info@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
 # sync built directory to a remote server
 
 - job-template:
@@ -17,7 +20,8 @@
       - string:
           name: BUILD_OUTPUT_PATH
           default: '{build-output-path}'
-          description: 'Path of files where build output is created by build command, relative to code checkout location'
+          description: >-
+            Path of files where build output is created by build command, relative to code checkout location
 
       - string:
           name: SYNC_TARGET_SERVER
@@ -30,7 +34,7 @@
           description: 'Directory path on target server where the files will be synced'
 
     triggers:
-      - cord-infra-gerrit-trigger-merge:
+      - onf-infra-gerrit-trigger-merge:
           gerrit-server-name: '{gerrit-server-name}'
           project-regexp: '^{project}$'
           branch-regexp: '{branch-regexp}'
@@ -38,30 +42,32 @@
           dependency-jobs: '{dependency-jobs}'
 
     properties:
-      - cord-infra-properties:
+      - onf-infra-properties:
           build-days-to-keep: '{build-days-to-keep}'
           artifact-num-to-keep: '{artifact-num-to-keep}'
 
     wrappers:
       - onf-infra-rsync-wrappers:
           build-timeout: '{build-timeout}'
-          jenkins-ssh-credential: '{gerrit-ssh-credential}'
+          ssh_credential_list:
+            - 'new-cord-jenkins-ssh'
 
     scm:
-      - lf-infra-gerrit-scm:
-          git-url: '$GIT_URL/$GERRIT_PROJECT'
+      - onf-infra-gerrit-scm:
+          git-url: '{gerrit-server-ssh-url}/$GERRIT_PROJECT'
           refspec: '$GERRIT_REFSPEC'
           branch: '$GERRIT_BRANCH'
           submodule-disable: '{submodule-disable}'
           submodule-recursive: 'false'
           submodule-timeout: '{submodule-timeout}'
           choosing-strategy: gerrit
-          jenkins-ssh-credential: '{gerrit-ssh-credential}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          basedir: ''
 
     node: '{build-node}'
     project-type: freestyle
     concurrent: true
 
     builders:
-      - shell: !include-raw-escape: ../shell/sync-dir.sh
+      - shell: !include-raw-escape: jjb/shell/sync-dir.sh
 
diff --git a/jjb/templates/versioning.yaml b/jjb/templates/versioning.yaml
new file mode 100644
index 0000000..82cfa20
--- /dev/null
+++ b/jjb/templates/versioning.yaml
@@ -0,0 +1,177 @@
+---
+# SPDX-FileCopyrightText: 2018-2022 Open Networking Foundation <info@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+# versioning jobs for tagging/releasing software
+
+# Versioning conventions:
+#
+# 1. There is a 1:1 relationship between SemVer _release_ versions described
+#    in the commit and the git tag applied to that commit by Jenkins.
+#
+# 2. Non-release versions (ex: 1.0.1-dev3, etc.) can exist in multiple
+#    commits, and don't trigger creation of git tags.
+#
+# 3. Git history is public, and therefore shouldn't be rewritten to abandon
+#    already merged commits
+#
+# 4. Reverting a commit leaves it in history, so if a broken version is
+#    released, the correct action is to make a new fixed version, not try to
+#    fix the released version
+#
+# For reference: https://jira.opencord.org/browse/CORD-3117
+
+- job-template:
+    id: tag-check
+    name: "tag-check_{project}"
+    description: |
+      Created by {id} job-template from ci-management/jjb/templates/versioning.yaml
+      Checks for changes to version files, and that they don't duplicate tags
+      already in the git repo.
+    disabled: '{disable-job}'
+
+    triggers:
+      - onf-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project-regexp}'
+          branch-regexp: '{branch-regexp}'
+          file-include-regexp: '{all-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - onf-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: '{gerrit-ssh-credential}'
+
+    scm:
+      - onf-infra-gerrit-scm:
+          git-url: '{gerrit-server-ssh-url}/$GERRIT_PROJECT'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-disable: '{submodule-disable}'
+          submodule-recursive: '{submodule-recursive}'
+          submodule-timeout: '{submodule-timeout}'
+          choosing-strategy: gerrit
+          jenkins-ssh-credential: '{gerrit-ssh-credential}'
+          basedir: '$GERRIT_PROJECT'
+
+    node: '{build-node}'
+    project-type: freestyle
+    concurrent: true
+
+    builders:
+      - inject:
+          properties-content: |
+            SEMVER_STRICT={semver-strict}
+            BASEDIR=$GERRIT_PROJECT
+      - shell: !include-raw-escape: jjb/shell/tag-check.sh
+
+- job-template:
+    id: version-tag
+    name: "version-tag_{project}"
+    disabled: '{disable-job}'
+    description: |
+      Created by {id} job-template from ci-management/jjb/templates/versioning.yaml
+      When a patch is merged, check if it contains a SemVer released version
+      file and if so tags thxe commit in git with that same version.
+
+    triggers:
+      - onf-infra-gerrit-trigger-merge:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project-regexp}'
+          branch-regexp: '{all-branches-regexp}'
+          file-include-regexp: '{all-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - onf-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:
+      - onf-infra-gerrit-scm:
+          git-url: '{gerrit-server-ssh-url}/$GERRIT_PROJECT'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-disable: '{submodule-disable}'
+          submodule-recursive: 'false'
+          submodule-timeout: '{submodule-timeout}'
+          choosing-strategy: gerrit
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          basedir: ''
+
+    node: '{build-node}'
+    project-type: freestyle
+    concurrent: true
+
+    builders:
+      - inject:
+          properties-content: |
+            SEMVER_STRICT={semver-strict}
+            BASEDIR=$GERRIT_PROJECT
+      - shell: !include-raw-escape: jjb/shell/version-tag.sh
+
+- job-template:
+    id: version-tag-github
+    name: "version-tag_{project}"
+    disabled: '{disable-job}'
+    description: |
+      Created by {id} job-template from ci-management/jjb/templates/versioning.yaml
+      When a patch is merged, check if it contains a SemVer released version
+      file and if so tags thxe commit in git with that same version.
+
+    properties:
+      - onf-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+      - github:
+          url: 'https://github.com/{github-organization}/{project}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    parameters:
+      - onf-infra-github-pr-merge-parameters:
+          repo-name: '{project}'
+          repo-url: '{github-ssh-url}{github-organization}/{project}.git'
+          branch: '{branch}'
+          commitHash: '{branch}'
+
+    triggers:
+      - onf-infra-github-pr-trigger:
+          github-token: '{github-token}'
+          status-context: 'Aether Jenkins - Makefile test'
+          trigger-phrase: '.*test\W+(make|makefile|version|versioning).*|{trigger-phrase}'
+          white-list-target-branches: '{white-list-target-branches}'
+          github_pr_org_list: '{obj:github_pr_org_list}'
+
+    scm:
+      - onf-infra-github-scm:
+          url: '{github-ssh-url}{github-organization}/{project}'
+          refspec: "{github-refspec-branch}"
+          branch: "$commitHash"
+          submodule-disable: "{submodule-disable}"
+          submodule-recursive: "{submodule-recursive}"
+          submodule-timeout: "{submodule-timeout}"
+          choosing-strategy: default
+          jenkins-ssh-credential: "{github-ssh-credential}"
+          basedir: ''
+
+    node: '{build-node}'
+    project-type: freestyle
+    concurrent: true
+
+    builders:
+      - shell: !include-raw-escape: jjb/shell/version-tag.sh