-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
81 lines (68 loc) · 1.84 KB
/
main.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
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
package main
import (
"fmt"
"os"
"github.com/kelseyhightower/envconfig"
"github.com/urbint/drone-sentry/sentry"
)
type Args struct {
ApiKey string `envconfig:"sentry_auth_token"`
Org string `envconfig:"sentry_organization"`
Project string `envconfig:"sentry_project"`
Environ string `envconfig:"sentry_release_environment"`
Version string `envconfig:"sentry_release_version"`
}
type DroneVars struct {
BuildNumber int `envconfig:"build_number"`
BuildFinished string `envconfig:"build_finished"`
BuildStatus string `envconfig:"build_status"`
BuildLink string `envconfig:"build_link"`
CommitSha string `envconfig:"commit_sha"`
CommitBranch string `envconfig:"commit_branch"`
CommitAuthor string `envconfig:"commit_author"`
CommitLink string `envconfig:"commit_link"`
CommitMessage string `envconfig:"commit_message"`
JobStarted int64 `envconfig:"job_started"`
Repo string `envconfig:"build_link"`
RepoLink string `envconfig:"repo_link"`
System string
}
func main() {
var (
err error
vargs Args
drone DroneVars
)
err = envconfig.Process("plugin", &vargs)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
err = envconfig.Process("sentry", &drone)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// create the Sentry client
client := sentry.NewClient(vargs.ApiKey, vargs.Org, vargs.Project)
// generate the Sentry objects
release := sentry.Release{
Version: vargs.Version,
Ref: "vargs.Version",
}
deploy := sentry.Deploy{
Name: vargs.Version,
Environment: vargs.Environ,
}
// sends the message
if err := client.CreateRelease(&release); err != nil {
fmt.Println("Error creating release")
fmt.Println(err)
os.Exit(1)
}
if err2 := client.CreateDeploy(&deploy); err2 != nil {
fmt.Println("Error creating deploy")
fmt.Println(err)
os.Exit(1)
}
}