[doctor] fix log cleaner and exclude joid testing
[releng.git] / jjb / global / releng-macros.yml
index 3afd355..19002fe 100644 (file)
@@ -1,4 +1,15 @@
-# OLD Releng macros
+# Releng macros
+#
+# NOTE: make sure macros are listed in execution ordered.
+#
+# 1. parameters/properties
+# 2. scm
+# 3. triggers
+# 4. wrappers
+# 5. prebuilders (maven only, configured like Builders)
+# 6. builders (maven, freestyle, matrix, etc..)
+# 7. postbuilders (maven only, configured like Builders)
+# 8. publishers/reporters/notifications
 
 - parameter:
     name: project-parameter
             name: GS_BASE_PROXY
             default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
             description: "URL to Google Storage proxy"
-
-- parameter:
-    name: gerrit-parameter
-    parameters:
+        - string:
+            name: BRANCH
+            default: '{branch}'
+            description: "JJB configured BRANCH parameter (e.g. master, stable/danube)"
         - string:
             name: GERRIT_BRANCH
             default: '{branch}'
-            description: "JJB configured GERRIT_BRANCH parameter"
+            description: "JJB configured GERRIT_BRANCH parameter (deprecated)"
+
+- property:
+    name: logrotate-default
+    properties:
+        - build-discarder:
+            days-to-keep: 60
+            num-to-keep: 200
+            artifact-days-to-keep: 60
+            artifact-num-to-keep: 200
 
 - scm:
     name: git-scm
     scm:
-        - git:
-            credentials-id: '{credentials-id}'
+        - git: &git-scm-defaults
+            credentials-id: '$SSH_CREDENTIAL_ID'
             url: '$GIT_BASE'
-            refspec: ''
             branches:
-                - 'origin/{branch}'
-            skip-tag: true
-            wipe-workspace: true
+                - 'origin/$BRANCH'
+            timeout: 15
 
 - scm:
-    name: gerrit-trigger-scm
+    name: git-scm-gerrit
     scm:
         - git:
-            credentials-id: '{credentials-id}'
-            url: '$GIT_BASE'
-            refspec: '{refspec}'
-            branches:
-                - 'origin/$GERRIT_BRANCH'
-            skip-tag: true
-            choosing-strategy: '{choosing-strategy}'
-            timeout: 15
+            choosing-strategy: 'gerrit'
+            refspec: '$GERRIT_REFSPEC'
+            <<: *git-scm-defaults
 
 - trigger:
     name: 'daily-trigger-disabled'
@@ -59,8 +72,9 @@
     triggers:
         - timed: ''
 
+# NOTE: unused macro, but we may use this for some jobs.
 - trigger:
-    name: gerrit-trigger-patch-submitted
+    name: gerrit-trigger-patchset-created
     triggers:
         - gerrit:
             server-name: 'gerrit.opnfv.org'
                     comment-contains-value: 'recheck'
             projects:
               - project-compare-type: 'ANT'
-                project-pattern: '{name}'
+                project-pattern: '{project}'
                 branches:
                   - branch-compare-type: 'ANT'
                     branch-pattern: '**/{branch}'
 
 - trigger:
-    name: gerrit-trigger-patch-merged
+    name: gerrit-trigger-change-merged
     triggers:
         - gerrit:
             server-name: 'gerrit.opnfv.org'
                     comment-contains-value: 'remerge'
             projects:
               - project-compare-type: 'ANT'
-                project-pattern: '{name}'
+                project-pattern: '{project}'
                 branches:
                   - branch-compare-type: 'ANT'
                     branch-pattern: '**/{branch}'
 
-- publisher:
-    name: archive-artifacts
-    publishers:
-        - archive:
-            artifacts: '{artifacts}'
-            allow-empty: true
-            fingerprint: true
-            latest-only: true
-
-# New Releng macros
+- trigger:
+    name: 'experimental'
+    triggers:
+        - gerrit:
+            server-name: 'gerrit.opnfv.org'
+            trigger-on:
+                - comment-added-contains-event:
+                    comment-contains-value: 'check-experimental'
+            projects:
+                - project-compare-type: 'ANT'
+                  project-pattern: '{project}'
+                  branches:
+                      - branch-compare-type: 'ANT'
+                        branch-pattern: '**/{branch}'
+                  file-paths:
+                      - compare-type: 'ANT'
+                        pattern: 'tests/**'
+            skip-vote:
+                successful: true
+                failed: true
+                unstable: true
+                notbuilt: true
+
+- wrapper:
+    name: ssh-agent-wrapper
+    wrappers:
+        - ssh-agent-credentials:
+            users:
+                - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
 
 - builder:
     name: build-html-and-pdf-docs-output
     name: check-bash-syntax
     builders:
         - shell: "find . -name '*.sh' | xargs bash -n"
+
+- builder:
+    name: lint-yaml-code
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o pipefail
+            set -o xtrace
+            export PATH=$PATH:/usr/local/bin/
+
+            # install python packages
+            pip install "yamllint==1.6.0"
+
+            # generate and upload lint log
+            echo "Running yaml code on $PROJECT ..."
+
+            # Ensure we start with a clean environment
+            rm -f yaml-violation.log lint.log
+
+            # Get number of yaml violations. If none, this will be an
+            # empty string: ""
+            find . \
+                -type f -name "*.yml" -print \
+                -o -name "*.yaml" -print | \
+                xargs yamllint > yaml-violation.log || true
+
+            if [ -s "yaml-violation.log" ]; then
+              SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
+              echo -e "First $SHOWN shown\n---" > lint.log
+              cat yaml-violation.log >> lint.log
+              sed -r -i '4,$s/^/ /g' lint.log
+            fi
+
+- builder:
+    name: clean-workspace-log
+    builders:
+        - shell: |
+            find $WORKSPACE -type f -name '*.log' | xargs rm -f
+
+- publisher:
+    name: archive-artifacts
+    publishers:
+        - archive:
+            artifacts: '{artifacts}'
+            allow-empty: true
+            fingerprint: true
+            latest-only: true