--- /dev/null
+#!/bin/bash
+CHANGE_ID=`ssh -p 29418 jenkins-$SILO@git.opendaylight.org gerrit query \
+ limit:1 owner:self is:open project:{project} \
+ message:'{gerrit-commit-message}' \
+ topic:{gerrit-topic} | \
+ grep 'Change-Id:' | \
+ awk '{{ print $2 }}'`
+
+if [ -z "$CHANGE_ID" ]; then
+ git commit -sm "{gerrit-commit-message}"
+else
+ git commit -sm "{gerrit-commit-message}" -m "Change-Id: $CHANGE_ID"
+fi
+
+git status
+git remote add gerrit ssh://jenkins-$SILO@git.opendaylight.org:29418/releng/builder.git
+
+# Don't fail the build if this command fails because it's possible that there
+# is no changes since last update.
+git review --yes -t {gerrit-topic} || true
- shell: !include-raw: opendaylight-infra-stack.sh
- shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
+- builder:
+ name: opendaylight-infra-push-gerrit-patch
+ # opendaylight-infra-push-gerrit-patch.sh allows a job to push a patch to
+ # Gerrit in an automated fashion. This is meant for tasks that creates
+ # the same patch regularly and needs the ability to detect if an unreviewed
+ # patch already exists. In which case it will update the existing patch.
+ #
+ # Note: This patch assumes the $WORKSPACE contains the project repo with
+ # the files changed already "git add" and waiting for a "git commit" call.
+ #
+ # This script requires the following JJB variables to be passed in:
+ # {project} Gerrit project-name
+ # {gerrit-topic} Gerrit topic, please make a unique topic.
+ # {gerrit-commit-message} Commit message to assign to commit.
+ builders:
+ - shell: !include-raw: opendaylight-infra-push-gerrit-patch.sh
+
- builder:
name: distribute-build-url
# Place URL of the current run of a build job to a file at given path.