Automate validate-autorelease job management 96/59996/5
authorThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 6 Jul 2017 05:14:00 +0000 (01:14 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 6 Jul 2017 23:38:59 +0000 (19:38 -0400)
Makes it so that humans no longer need to remember to update these
things.

Issue: RELENG-281
Change-Id: Ic46703ee00f964bba5578ddc4b6322199bb6071b
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/autorelease/autorelease-projects.yaml
jjb/autorelease/autorelease-templates.yaml
jjb/autorelease/update-validate-autorelease-projects.sh [new file with mode: 0644]

index 612dd9f51085b8e8bb735a9c8d89a310175dfa0e..82cf695a323b755741651cdcc8e8cd1e58a50424 100644 (file)
@@ -4,6 +4,7 @@
     jobs:
       - 'autorelease-generate-release-notes-{stream}'
       - 'autorelease-release-{stream}'
+      - 'autorelease-update-validate-jobs-{stream}'
       - 'autorelease-version-bump-{stream}'
       - '{project-name}-validate-autorelease-{stream}'
 
index 95800c190394b663388f05f7c3e9bd7fbeeca059..638afa20a189c5d94df89044c54d6ee8f3c45627 100644 (file)
             fail-on-missing: true
       - lf-infra-publish
 
+- job-template:
+    name: autorelease-update-validate-jobs-{stream}
+    project-type: freestyle
+    node: centos7-java-builder-2c-4g
+
+    properties:
+      - lf-infra-properties:
+          build-days-to-keep: 7
+
+    parameters:
+      - lf-infra-parameters:
+          project: releng/builder
+          branch: '{branch}'
+          stream: '{stream}'
+
+    scm:
+      - lf-infra-gerrit-scm:
+          git-url: '$GIT_URL/releng/builder'
+          branch: master
+          refspec: 'refs/heads/master'
+          jenkins-ssh-credential: opendaylight-jenkins-ssh
+          submodule-recursive: true
+          choosing-strategy: default
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on:
+            - change-merged-event
+            - comment-added-contains-event:
+                comment-contains-value: remerge$
+          projects:
+            - project-compare-type: ANT
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: '**/{branch}'
+              file-paths:
+                - compare-type: ANT
+                  pattern: pom.xml
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: 10
+          jenkins-ssh-credential: opendaylight-jenkins-ssh
+
+    builders:
+      - shell: !include-raw-escape:
+          - update-validate-autorelease-projects.sh
+      - opendaylight-infra-push-gerrit-patch:
+          project: 'releng/builder'
+          gerrit-topic: 'autorelease-update-validate-jobs-{stream}'
+          gerrit-commit-message: |
+              Update validate autorelease projects for {stream}
+
+    publishers:
+      - lf-infra-publish
+
 - job-template:
     name: autorelease-version-bump-{stream}
     project-type: freestyle
diff --git a/jjb/autorelease/update-validate-autorelease-projects.sh b/jjb/autorelease/update-validate-autorelease-projects.sh
new file mode 100644 (file)
index 0000000..e29d3fe
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+YAML_FILE="${WORKSPACE}/jjb/autorelease/validate-autorelease-${STREAM}.yaml"
+BRANCH="stable/${STREAM}"
+
+# The current development release will not have a stable branch defined so if
+# branch does not exist assume master
+wget --no-verbose -O /tmp/ar-branches.json https://git.opendaylight.org/gerrit/projects/releng%2Fautorelease/branches/
+if ! grep "$BRANCH" /tmp/ar-branches.json; then
+    BRANCH=master
+fi
+
+wget --no-verbose -O /tmp/pom.xml "https://git.opendaylight.org/gerrit/gitweb?p=releng/autorelease.git;a=blob_plain;f=pom.xml;hb=$GERRIT_BRANCH"
+modules=($(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' /tmp/pom.xml))
+
+cat > "$YAML_FILE" << EOF
+---
+# Autogenerated by autorelease autorelease-update-validate-autorelease-jobs-{stream} Jenkins job
+- project:
+    name: autorelease-validate-${STREAM}
+    jobs:
+      - '{project-name}-validate-autorelease-{stream}'
+    stream: ${STREAM}
+    branch: ${BRANCH}
+    project-name:
+EOF
+
+for module in "${modules[@]}"; do
+    echo "Include $module"
+    echo "      - $module:" >> "$YAML_FILE"
+    echo "          project: $module" >> "$YAML_FILE"
+done
+
+git add "${YAML_FILE}"