Final patch for [AETHER-778], [AETHER-779] and [AETHER-782]

- Enables new CI/CD jobs for stable and master builds
- Disable old CI/CD jobs
- Removes taggging step from the publish script
- Add weekly job for master

Change-Id: Ie99565305c9f5119503d218097771ed69e80a656
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index fa39327..ba88535 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -117,3 +117,7 @@
     # maintainers
     # Used to notify users in supported tests
     maintainers: 'zdw@opennetworking.org'
+
+    # timed
+    # Used as default for timed triggers
+    timed: '@midnight'
diff --git a/jjb/pipeline/tost-onos-publish.groovy b/jjb/pipeline/tost-onos-publish.groovy
index a07e782..1579733 100644
--- a/jjb/pipeline/tost-onos-publish.groovy
+++ b/jjb/pipeline/tost-onos-publish.groovy
@@ -37,7 +37,7 @@
           ],
         ])
         script {
-          git_tags = sh(script:"cd $projectName; git tag -l --points-at HEAD", returnStdout: true).trim()
+          current_date = sh(returnStdout: true, script: 'date +%Y-%m-%d').trim()
         }
       }
     }
@@ -58,6 +58,11 @@
                 export DOCKER_REGISTRY="$dockerRegistry/"
                 export DOCKER_REPOSITORY="$dockerRepo/"
 
+                # Builds having a build date
+                if [ ! -z "$buildDate" ]; then
+                  export DOCKER_TAG_BUILD_DATE="-$current_date"
+                fi
+
                 # Build w/extraEnvironmentVars
                 echo "Building image with following vars $extraEnvironmentVars"
                 $extraEnvironmentVars make docker-build 2>&1 | tee "$WORKSPACE/docker-build.log"
@@ -83,6 +88,11 @@
               export DOCKER_REGISTRY="$dockerRegistry/"
               export DOCKER_REPOSITORY="$dockerRepo/"
 
+                # Builds having a build date
+                if [ ! -z "$buildDate" ]; then
+                  export DOCKER_TAG_BUILD_DATE="-$current_date"
+                fi
+
               # Push w/extraEnvironmentVars
               echo "Pushing image with following vars $extraEnvironmentVars"
               $extraEnvironmentVars make docker-push 2>&1 | tee "$WORKSPACE/docker-push.log"
diff --git a/jjb/repos/tost-onos.yaml b/jjb/repos/tost-onos.yaml
index 92a7d58..623c835 100644
--- a/jjb/repos/tost-onos.yaml
+++ b/jjb/repos/tost-onos.yaml
@@ -20,15 +20,18 @@
 
     jobs:
       - 'verify-licensed'
+      # Tag check is currently disabled because we have temporarily
+      # abandoned the SemVer format
       - 'tag-check':
-          dependency-jobs: 'license-check_tost-onos'
           disable-job: true
+          dependency-jobs: 'license-check_tost-onos'
+      # Job based on the SemVer DOCKER_TAG
       - 'private-make-test':
+          disable-job: true
           make-test-targets: 'docker-build'
           junit-allow-empty-results: true
           build-node: '{bigger-build-node}'
       - 'private-make-test':
-          disable-job: true
           target: 'master'
           name-extension: '-{target}'
           make-test-vars: 'DOCKER_TAG={target}'
@@ -36,36 +39,31 @@
           junit-allow-empty-results: true
           build-node: '{bigger-build-node}'
       - 'private-make-test':
-          disable-job: true
           target: 'stable'
           name-extension: '-{target}'
           make-test-vars: 'DOCKER_TAG={target}'
           make-test-targets: 'docker-build'
           junit-allow-empty-results: true
           build-node: '{bigger-build-node}'
-      - 'private-make-test':
-          disable-job: true
-          target: 'devel'
-          name-extension: '-{target}'
-          make-test-vars: 'DOCKER_TAG={target}'
-          make-test-targets: 'docker-build'
-          junit-allow-empty-results: true
-          build-node: '{bigger-build-node}'
 
 - job-group:
     name: 'publish-tost-onos-jobs'
 
     jobs:
+      # Tag check is currently disabled because we have temporarily
+      # abandoned the SemVer format
       - 'version-tag':
           disable-job: true
+      # Job based on the SemVer DOCKER_TAG
       - 'private-docker-publish':
+          disable-job: true
           docker-repo: 'tost'
           docker-registry: 'registry.aetherproject.org'
           maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
           build-timeout: 30
           dependency-jobs: 'version-tag_tost-onos'
+      # Post-merge and nightly triggered
       - 'tost-onos-docker-publish':
-          disable-job: true
           target: 'master'
           name-extension: '-{target}'
           extraEnvironmentVars: 'DOCKER_TAG={target}'
@@ -73,8 +71,19 @@
           docker-registry: 'registry.aetherproject.org'
           maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
           build-timeout: 30
+          buildDate: ''
+      # Weekly triggered
+      - 'weekly-tost-onos-docker-publish':
+          target: 'master'
+          name-extension: '-{target}'
+          extraEnvironmentVars: 'DOCKER_TAG={target}'
+          docker-repo: 'tost'
+          docker-registry: 'registry.aetherproject.org'
+          maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
+          build-timeout: 30
+          timed: 'H 0 * * 5'
+      # Post-merge only
       - 'tost-onos-docker-publish':
-          disable-job: true
           target: 'stable'
           name-extension: '-{target}'
           extraEnvironmentVars: 'DOCKER_TAG={target}'
@@ -82,15 +91,7 @@
           docker-registry: 'registry.aetherproject.org'
           maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
           build-timeout: 30
-      - 'tost-onos-docker-publish':
-          disable-job: true
-          target: 'devel'
-          name-extension: '-{target}'
-          extraEnvironmentVars: 'DOCKER_TAG={target}'
-          docker-repo: 'tost'
-          docker-registry: 'registry.aetherproject.org'
-          maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
-          build-timeout: 30
+          timed: ''
 
 - job-group:
     name: 'release-tost-onos-jobs'
diff --git a/jjb/templates/tost-onos-jobs.yaml b/jjb/templates/tost-onos-jobs.yaml
index 50bbbef..3e03cf3 100644
--- a/jjb/templates/tost-onos-jobs.yaml
+++ b/jjb/templates/tost-onos-jobs.yaml
@@ -7,7 +7,7 @@
     description: |
       Created by {id} job-template from ci-management/jjb/tost-onos-jobs.yaml, script pipeline/tost-onos-publish.groovy<br/>
       Runs docker-build with the following env. variables - '{extraEnvironmentVars}' and then publish the image on {docker-registry}/{docker-repo}. <br/>
-      Triggered also nightly. <br/>
+      Triggered also at {timed}. <br/>
 
     triggers:
       - onf-infra-gerrit-trigger-merge:
@@ -16,7 +16,7 @@
           branch-regexp: '{branch-regexp}'
           file-include-regexp: '{all-files-regexp}'
           dependency-jobs: '{dependency-jobs}'
-      - timed: "@midnight"
+      - timed: '{timed}'
 
     properties:
       - onf-infra-onfstaff-private:
@@ -86,9 +86,107 @@
           default: '{extraEnvironmentVars}'
           description: "Provide extra environment variables to the build"
 
+      - string:
+          name: buildDate
+          default: '{buildDate}'
+          description: "To add the build date to the tag"
+
     project-type: pipeline
     concurrent: true
     extraEnvironmentVars: ""
     sandbox: true
+    buildDate: 'true'
+
+    dsl: !include-raw-escape: ../pipeline/tost-onos-publish.groovy
+
+- job-template:
+    id: weekly-tost-onos-docker-publish
+    name: 'weekly-tost-onos-docker-publish{name-extension}'
+    disabled: '{disable-job}'
+    description: |
+      Created by {id} job-template from ci-management/jjb/tost-onos-jobs.yaml, script pipeline/tost-onos-publish.groovy<br/>
+      Runs {timed} docker-build with the following env. variables - '{extraEnvironmentVars}' and then publish the image on {docker-registry}/{docker-repo}. <br/>
+
+    triggers:
+      - timed: '{timed}'
+
+    properties:
+      - onf-infra-onfstaff-private:
+      - 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}'
+
+    parameters:
+      - string:
+          name: buildNode
+          default: '{bigger-build-node}'
+          description: 'Name of the Jenkins build executor to run the job on'
+
+      - string:
+          name: gitUrl
+          default: '$GIT_URL/$GERRIT_PROJECT'
+          description: 'URL to the git repo'
+
+      - string:
+          name: GERRIT_PATCHSET_REVISION
+          default: 'master'
+          description: 'git ref to build (commit hash or tag)'
+
+      - string:
+          name: GERRIT_REFSPEC
+          default: 'refs/heads/master'
+          description: 'git refSpec to build (refs/changes/)'
+
+      - string:
+          name: GERRIT_PROJECT
+          default: 'tost-onos'
+          description: 'Name of the project in Gerrit'
+
+      - string:
+          name: GERRIT_BRANCH
+          default: 'master'
+          description: 'Branch of the project in Gerrit'
+
+      - string:
+          name: dockerRepo
+          default: '{docker-repo}'
+          description: "Docker repository to push to ('onosproject', etc.)"
+
+      - string:
+          name: dockerRegistry
+          default: '{docker-registry}'
+          description: "Docker registry to push to (blank for DockerHub)"
+
+      # AWS CPU arch names: `x86_64` `arm64` (which don't align to vendor names... *sigh*)
+      - string:
+          name: dockerArchList
+          default: 'x86_64'
+          description: "List of architectures to build containers on, pipe separated (nonfunctional currently)"
+
+      - string:
+          name: maintainers
+          default: '{maintainers}'
+          description: "The person that should be notified if this job fails"
+
+      - string:
+          name: extraEnvironmentVars
+          default: '{extraEnvironmentVars}'
+          description: "Provide extra environment variables to the build"
+
+      - string:
+          name: buildDate
+          default: '{buildDate}'
+          description: "To add the build date to the tag"
+
+    project-type: pipeline
+    concurrent: true
+    extraEnvironmentVars: ""
+    sandbox: true
+    buildDate: 'true'
 
     dsl: !include-raw-escape: ../pipeline/tost-onos-publish.groovy