-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathci_submit
executable file
·93 lines (80 loc) · 2.77 KB
/
ci_submit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
# SPDX-Identifier: gpl-2.0-or-later
# Copyright (C) 2018, Red Hat, Inc.
#
# Monitors the series database for new series that have not been submitted.
# Submits the series to a ci backend job.
# Licensed under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. You may obtain a copy of the
# license at
#
# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
[ -f "${HOME}/.cisub-rc" ] && source "${HOME}/.cisub-rc"
[ -f "${HOME}/.pwmon-rc" ] && source "${HOME}/.pwmon-rc"
if [ "X$ci_backend" == "X" ]; then
echo "ERROR: CI server is not set."
echo "Please setup ${HOME}/.cisub-rc and set the ci_backend"
echo
exit 1
fi
if [ "$1" != "" ]; then
pw_project="$1"
shift
fi
if [ "$1" != "" ]; then
pw_instance="$1"
fi
if [ "X$pw_project" == "X" -o "X$pw_instance" == "X" ]; then
echo "ERROR: Patchwork project is unset."
echo "Please setup ${HOME}/.cisub-rc and set pw_project "
echo "Please setup ${HOME}/.cisub-rc and set pw_instance "
echo "(or pass it as an argument)."
exit 1
fi
source $(dirname $0)/series_db_lib.sh
source $(dirname $0)/${ci_backend}_lib.sh
function ci_submit_job() {
instance="$1"
id="$2"
url="$3"
submitter_name="$4"
submitter_email="$5"
echo "Submit JOB:"
echo " INSTANCE: $instance"
echo " ID: $id"
echo " URL: $url"
echo " Submitter: $submitter_name <$submitter_email>"
if ${ci_backend}_submit_series "$instance" "$id" "$url" "$submitter_name" "$submitter_email"; then
series_id_set_submitted "$instance" "$id"
return 0
fi
return 1
}
function ci_get_variable() {
local value_var="$1"
if [ "$value_var" == "series_id" ]; then
echo "${id}"
elif [ "$value_var" == "series_url" ]; then
echo "${url}"
elif [ "$value_var" == "series_submitter_name" ]; then
echo "${submitter_name}"
elif [ "$value_var" == "series_submitter_email" ]; then
echo "${submitter_email}"
elif [ "$value_var" == "series_instance" ]; then
echo "${pw_instance}"
else
echo "$value_var"
fi
}
get_unsubmitted_jobs_as_line "$pw_instance" "$pw_project" | while IFS=\| read -r id url submitter_name submitter_email; do
if ! ci_submit_job "$pw_instance" "$id" "$url" "$submitter_name" "$submitter_email"; then
echo "Unable to submit job with series id: $id"
fi
done