-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrone.go
47 lines (41 loc) · 1.06 KB
/
drone.go
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
package main
import (
"log"
"os"
"strings"
)
type Build struct {
BuildNumber string
BuildEvent string
BuildLink string
Repo string
RepoLink string
Branch string
CommitBefore string
CommitAfter string
CommitLink string
Author string
Status string
}
func getenvStrict(key string) string {
res := os.Getenv(key)
if res == "" {
log.Fatalf("%s: required variable not defined", key)
}
return res
}
func getBuildInfo() Build {
return Build{
BuildNumber: getenvStrict("DRONE_BUILD_NUMBER"),
BuildEvent: getenvStrict("DRONE_BUILD_EVENT"),
BuildLink: getenvStrict("DRONE_BUILD_LINK"),
Repo: getenvStrict("DRONE_REPO"),
RepoLink: getenvStrict("DRONE_REPO_LINK"),
Branch: getenvStrict("DRONE_SOURCE_BRANCH"),
CommitBefore: getenvStrict("DRONE_COMMIT_BEFORE"),
CommitAfter: getenvStrict("DRONE_COMMIT_AFTER"),
CommitLink: getenvStrict("DRONE_COMMIT_LINK"),
Author: getenvStrict("DRONE_COMMIT_AUTHOR"),
Status: strings.ToUpper(getenvStrict("DRONE_BUILD_STATUS")),
}
}