Rework Jenkins Sandbox 75/22575/2
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Tue, 27 Sep 2016 20:27:57 +0000 (13:27 -0700)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Thu, 29 Sep 2016 19:57:31 +0000 (12:57 -0700)
- Instead of using 'sandbox' branch, use a seperate jjb tree.
- Jobs under 'jjb-sandbox' are uploaded to the sandbox server, and can
  be re-uploaded with a 'redeploy' comment.
- All jobs, with the exception of the releng sandbox jobs, on the
  sandbox server are removed once a week.

JIRA: RELENG-91

Change-Id: Idfaf33b547158280378ecc63aa41db1b806f4c5f
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
jjb-sandbox/releng/releng-sandbox-jobs.yml [new file with mode: 0644]
jjb-sandbox/releng/verify-sandbox-jobs.sh [new file with mode: 0755]
jjb/releng/releng-ci-jobs.yml

diff --git a/jjb-sandbox/releng/releng-sandbox-jobs.yml b/jjb-sandbox/releng/releng-sandbox-jobs.yml
new file mode 100644 (file)
index 0000000..ee35f42
--- /dev/null
@@ -0,0 +1,77 @@
+- project:
+    name: 'releng-sandbox-jobs'
+    jobs:
+        - 'releng-deploy-sandbox'
+        - 'releng-clear-jenkins-jobs'
+
+    project: 'releng'
+
+- job-template:
+    name: 'releng-deploy-sandbox'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: 'master'
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: '$GERRIT_REFSPEC'
+            choosing-strategy: 'gerrit'
+
+    triggers:
+        - gerrit:
+            trigger-on:
+                - patchset-created-event:
+                    exclude-drafts: 'false'
+                    exclude-trivial-rebase: 'false'
+                    exclude-no-code-change: 'false'
+                - draft-published-event
+                - comment-added-contains-event:
+                    comment-contains-value: 'redeploy'
+            projects:
+              - project-compare-type: 'ANT'
+                project-pattern: 'releng'
+                branches:
+                  - branch-compare-type: 'ANT'
+                    branch-pattern: '**/master'
+                file-paths:
+                    - compare-type: ANT
+                      pattern: jjb-sandbox/**
+                    - compare-type: ANT
+                      pattern: utils/**
+
+    builders:
+        - shell:
+            !include-raw-escape: verify-sandbox-jobs.sh
+        - shell: |
+            #! /bin/bash
+            jenkins-jobs update -r jjb-sandbox
+
+    publishers:
+        - archive-artifacts:
+            artifacts: 'job_output/*'
+
+- job-template:
+    name: 'releng-clear-jenkins-jobs'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: 'master'
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: ''
+            choosing-strategy: 'default'
+
+    triggers:
+        - timed: '@weekly'
+
+    builders:
+        - shell: |
+            #! /bin/bash
+            jenkins-jobs delete -r -p jjb-sandbox -x jjb-sandbox/releng
diff --git a/jjb-sandbox/releng/verify-sandbox-jobs.sh b/jjb-sandbox/releng/verify-sandbox-jobs.sh
new file mode 100755 (executable)
index 0000000..8f67e74
--- /dev/null
@@ -0,0 +1,21 @@
+#! /bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 Linux Foundation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+#test for non-ascii characters, these can pass the test and end up breaking things in production
+for x in $(find . -name *\.yml); do
+
+  if LC_ALL=C grep -q '[^[:print:][:space:]]' "$x"; then
+    echo "file "$x" contains non-ascii characters"
+    exit 1
+  fi
+
+done
+
+jenkins-jobs test -r jjb/releng-defaults.yaml:jjb/releng-macros.yaml:jjb/opnfv/installer-params.yml:jjb/opnfv/slave-params.yml:jjb-sandbox \
+    -o job_output
index ac323a3..2d88449 100644 (file)
@@ -2,7 +2,6 @@
     name: builder-jobs
     jobs:
         - 'builder-verify-jjb'
-        - 'builder-sandbox'
         - 'builder-merge'
         - 'artifacts-api'
 
                 git pull
                 jenkins-jobs update -r --delete-old jjb/
 
-- job-template:
-    name: 'builder-sandbox'
-
-    # Upload all jjb jobs to sandbox instance, excluding jobs jjb
-    # builder jobs
-
-    parameters:
-        - project-parameter:
-            project: '{project}'
-        - gerrit-parameter:
-            branch: 'master'
-
-    scm:
-        - gerrit-trigger-scm:
-            credentials-id: '{ssh-credentials}'
-            refspec: ''
-            choosing-strategy: 'default'
-
-    triggers:
-        - gerrit:
-            trigger-on:
-                - change-merged-event
-                - comment-added-contains-event:
-                    comment-contains-value: 'remerge'
-            projects:
-              - project-compare-type: 'ANT'
-                project-pattern: 'releng'
-                branches:
-                    - branch-compare-type: 'ANT'
-                      branch-pattern: '**/sandbox'
-                file-paths:
-                    - compare-type: ANT
-                      pattern: jjb/**
-                    - compare-type: ANT
-                      pattern: utils/**
-
-    builders:
-        - shell:
-            !include-raw: verify-releng.sh
-        - shell: |
-                #!/bin/bash
-                source /opt/virtualenv/jenkins-job-builder/bin/activate
-                cd /opt/jenkins-ci/releng
-                git pull
-                cp /etc/jenkins_jobs/jenkins_jobs.ini jenkins_sandbox.ini
-                sed -i 's/url=.*/url=https:\/\/sandbox.opnfv.org\//g' jenkins_sandbox.ini
-                jenkins-jobs --conf jenkins_sandbox.ini update -r -x jjb/releng --delete-old jjb
-                rm -f jenkins_sandbox.ini
-
 - job-template:
     name: 'artifacts-api'