-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_steps.sh
58 lines (48 loc) · 1.27 KB
/
build_steps.sh
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
#!/bin/bash
set -eoux pipefail
# Pass the Build Hash as a Env
KEY_PATH="/home/pi/keys/gittoken.json"
PR_BUILDER="Unwind_Build_PullRequest"
PR_BUILD_URL="https://f8e9056a4af3.ngrok.io/job/$PR_BUILDER/$BUILD_NUMBER/console"
function check_dir() {
echo $PWD
ls -al
}
function build_docker() {
docker build -t unwindtest:$BUILD_NUMBER .
docker images
}
function run_docker() {
docker run --rm unwindtest:$BUILD_NUMBER /bin/sh -c "ls -al && echo $PWD && \
go test -v ./..."
}
function run_server() {
#TODO: Future PR work
docker run --rm -p 3000:3000 unwindtest:$BUILD_NUMBER
}
function extract_token() {
token=$(jq '.token' $KEY_PATH)
token="${token%\"}"
token="${token#\"}"
echo $token
}
function post_gitStatus_success() {
#TODO: Future PR work
echo "Post status after build succeeds"
git_token=$(extract_token)
URL="https://api.GitHub.com/repos/<>/<>/statuses/$GIT_COMMIT?access_token=$git_token"
curl "$URL" \
-H "Content-Type: application/json" \
-X POST \
-d "{
\"state\": \"success\",
\"context\": \"continuous-integration/jenkins\",
\"description\": \"Jenkins\",
\"target_url\": $PR_BUILD_URL
}" >> output.txt
}
function push_docker() {
# Push Docker image to Dockerhub
echo "Push Step"
}
$1