forked from kubernetes/release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_green_build
executable file
·121 lines (109 loc) · 3.76 KB
/
find_green_build
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#
# Set PROGram name
PROG=${0##*/}
########################################################################
#+
#+ NAME
#+ $PROG - Find a good Kubernetes build from Jenkins
#+
#+ SYNOPSIS
#+ $PROG [--official] [<release branch>]
#+ [--github-token=<token>]
#+ $PROG [--helpshort|--usage|-?]
#+ $PROG [--help|-man]
#+
#+ DESCRIPTION
#+ Scan defined Jenkins instances for 2 contiguous successful runs
#+ to validate the state of the tree and then return build and release
#+ versions for use by the release tools or just for fun.
#+
#+ With no args, $PROG works on master. Otherwise it works on the named
#+ release branch (ie. release-1.2) and optionally produces
#+ --official versions.
#+
#+ OPTIONS
#+ [--official] - Produce an official release version for a
#+ release branch
#+ --github-token= - Must be specified if GITHUB_TOKEN not set
#+ [--help | -man] - display man page for this script
#+ [--usage | -?] - display in-line usage
#+
#+ EXAMPLES
#+ $PROG - Produce versions for master
#+ $PROG release-1.2 - Produce versions for release-1.2
#+
#+ FILES
#+
#+ SEE ALSO
#+ common.sh - base function definitions
#+ anago - release tool
#+ relnotes - release notes generator
#+
#+ BUGS/TODO
#+
########################################################################
# If NO ARGUMENTS should return *usage*, uncomment the following line:
#usage=${1:-yes}
source $(dirname $(readlink -ne $BASH_SOURCE))/lib/common.sh
source $TOOL_LIB_PATH/gitlib.sh
source $TOOL_LIB_PATH/releaselib.sh
# Validate command-line
common::argc_validate 1 || common::exit 1 "Exiting..."
###############################################################################
# common::cleanexit prog-specific override function
# Do stuff here to clean up after this specific script
# @param exit code
#
common::cleanexit () {
rm -rf $LOCAL_CACHE
common::timestamp end
exit ${1:-0}
}
###############################################################################
# MAIN
###############################################################################
# BEGIN script
common::timestamp begin
# Force verbose flag
FLAGS_verbose=1
# Initialize and save up to 10 (rotated logs)
MYLOG=/tmp/$PROG.log
common::logfileinit $MYLOG 10
gitlib::github_api_token
common::check_packages jq
common::set_cloud_binaries
# Blank for master
RELEASE_BRANCH=${POSITIONAL_ARGV[0]:-"master"}
if (($FLAGS_official)) && [[ "$RELEASE_BRANCH" == "master" ]]; then
common::exit 1 "Can't do official releases on master!"
fi
# Are we branching to a new branch?
if gitlib::branch_exists $RELEASE_BRANCH; then
TESTING_BRANCH=$RELEASE_BRANCH
BRANCH_OFF_MASTER=0
else
(($FLAGS_official)) && \
common::exit 1 "Can't do official releases when creating a new branch!"
TESTING_BRANCH=master
BRANCH_OFF_MASTER=1
fi
logecho
release::set_build_version $TESTING_BRANCH $LOCAL_CACHE || common::exit 1
release::set_release_version $JENKINS_BUILD_VERSION $RELEASE_BRANCH \
$BRANCH_OFF_MASTER || common::exit 1
common::exit 0