Chore: Update gerrit-review-action to latest v0.8
[releng/builder.git] / jjb / opendaylight-infra-push-gerrit-patch.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 # Install git-review using virtualenv to the latest version that supports
13 # --reviewers option, available through pip install. Existing minion image has a
14 # version that does not have it.
15 virtualenv "/tmp/v/git-review"
16 # shellcheck source=/tmp/v/git-review/bin/activate disable=SC1091
17 source "/tmp/v/git-review/bin/activate"
18 pip install --upgrade "pip<10.0.0" setuptools
19 pip install --upgrade git-review
20 pip freeze
21
22 # shellcheck disable=SC1083
23 CHANGE_ID=$(ssh -p 29418 "jenkins-$SILO@git.opendaylight.org" gerrit query \
24                limit:1 owner:self is:open project:{project} \
25                message:'{gerrit-commit-message}' \
26                topic:{gerrit-topic} | \
27                grep 'Change-Id:' | \
28                awk '{{ print $2 }}')
29
30 if [ -z "$CHANGE_ID" ]; then
31     git commit -sm "{gerrit-commit-message}"
32 else
33     git commit -sm "{gerrit-commit-message}" -m "Change-Id: $CHANGE_ID"
34 fi
35
36 git status
37 git remote add gerrit "ssh://jenkins-$SILO@git.opendaylight.org:29418/releng/builder.git"
38
39 # Don't fail the build if this command fails because it's possible that there
40 # is no changes since last update.
41 # shellcheck disable=SC1083
42 git review --yes -t {gerrit-topic} --reviewers jluhrsen@redhat.com || true