-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfor-kg.txt
executable file
·128 lines (108 loc) · 3.01 KB
/
for-kg.txt
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
122
123
124
#!/bin/bash
env_arr=(asia-es1 asia-es2 eu-a eu-b pdev-cn prd-cn)
cmd_arr=(update delete adddns)
type_arr=(external internal)
minorVersion=""
if [ "$1" == "-h" ] ; then
cat << EOF
*****************************************************************
* Initializing system, please try later!
* Power by Lex. Let's go! and be happy!
* version 1.0
echo "Examples:"
echo " $0 -e asia-es1 -c update -t external -v 1.1.1"
*****************************************************************
EOF
exit 0
fi
while getopts ":e:c:t:v:h:" o; do
case $o in
e) e=${OPTARG}
[[ " ${env_arr[*]} " == *" $e "* ]] || usage
;;
c) c=${OPTARG}
[[ " ${cmd_arr[*]} " == *" $c "* ]] || usage
;;
t) t=${OPTARG}
[[ " ${type_arr[*]} " == *" $t "* ]] || usage
;;
v) v=${OPTARG}
minorVersion=$OPTARG
;;
h) echo "a script to "
echo "Usage:"
echo "$0 -h"
echo "$0 [-H hostname] [-P port] [-u username] [-p password] \\"
echo " [-q] [-s seconds] [-w limits] [-c limits]"
echo "Source:"
;;
*) esac
done
if [ ! "$e" ] || [ "$minorVersion" == "" ]; then
echo "please enter env and api region" >&2
exit 1
fi
case $e in
"asia-es1")
project=china-010115-ddd-dev
;;
"asia-es2")
project=china-0290910-pp-dev
;;
"eu-a"|"eu-b")
project=china-0290910-aaa-dev
;;
"prd-cn") project=china-apichina-prod;;
*) echo "Error input space and region!"
exit 1
esac
echo $project
if [ ! "$c" ]; then
echo "please enter your command" >&2
exit 1
fi
if [ ! "$t" ]; then
echo "please enter your type" >&2
exit 1
fi
case $t in #type
"external")
echo "external"
fqdnname=$e-$t-$minorVersion-external.sb.domain.com
;;
"internal")
echo "internal"
fqdnname=$e-$t-$minorVersion-internal.sb.domain.com
;;
*) echo "Error input type!"
exit 1
esac
echo "$fqdnname"
import groovy.json.JsonSlurper
import org.apache.http.HttpEntity
import org.apache.http.client.methods.CloseableHttpResponse
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClients
def baseUrl = "https://api.github.com"
def owner = "OWNER"
def repo = "REPO"
def prNumber = 123
def client = HttpClients.createDefault()
def url = "${baseUrl}/repos/${owner}/${repo}/pulls/${prNumber}"
def get = new HttpGet(url)
get.setHeader("Accept", "application/vnd.github.v3+json")
CloseableHttpResponse response = client.execute(get)
HttpEntity entity = response.getEntity()
def json = new JsonSlurper().parseText(entity.getContent().text)
if (response.getStatusLine().getStatusCode() == 404) {
println("The pull request does not exist.")
} else if (json.head.sha == null) {
println("The pull request is not ready to be merged.")
} else if (json.merged_at != null) {
println("The pull request has already been merged.")
} else {
println("The pull request is ready to be merged.")
}
response.close()
client.close()