Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

## pretriage

Usage:
**Usage:**

```shell
go build ./cmd/pretriage && ./pretriage`
```

Finds untriaged, unassigned Shiftstack bugs and assigns them to a team member.

Required environment variables:
**Required environment variables:**

* `JIRA_TOKEN`: a [Jira API token](https://issues.redhat.com/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens) of an account that can access the OCPBUGS project
* `SLACK_HOOK`: a [Slack hook](https://api.slack.com/messaging/webhooks) URL
* `TEAM_MEMBERS_DICT` is a JSON object in the form:
* `TEAM_MEMBERS_DICT`: a JSON object in the form:

```json
{
Expand All @@ -34,7 +35,9 @@ Required environment variables:
}
```

Optional environment variable: `TEAM_VACATION` in the form:
**Optional environment variables:**

* `TEAM_VACATION`: a JSON object in the form:

```json
[
Expand All @@ -53,28 +56,34 @@ Optional environment variable: `TEAM_VACATION` in the form:

## posttriage

Usage:
**Usage:**

```shell
go build ./cmd/posttriage && ./posttriage
```

Resets the `Triaged` keyword on bugs that still need attention.

Required environment variables:
**Required environment variables:**

* `JIRA_TOKEN`: a [Jira API token](https://issues.redhat.com/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens) of an account that can access the OCPBUGS project

## doctext

Usage:
**Usage:**

```shell
go build ./cmd/doctext && ./doctext
```

Finds resolved bugs lacking a doc text, and posts a reminder to Slack.

Required environment variables:
**Required environment variables:**

* `JIRA_TOKEN`: a [Jira API token](https://issues.redhat.com/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens) of an account that can access the OCPBUGS project
* `SLACK_HOOK`: a [Slack hook](https://api.slack.com/messaging/webhooks) URL
* `TEAM_MEMBERS_DICT` is a JSON object in the form:
* `SLACK_HOOK`: a [Slack hook](https://api.slack.com/messaging/webhooks) URL (optional and ignored if `BUGWATCHER_DEBUG` set)
* `TEAM_MEMBERS_DICT`: a JSON object in the form described previously (optional and ignored if `BUGWATCHER_DEBUG` set)

**Optional environment variables:**

* `BUGWATCHER_DEBUG`: enable debug mode, where found bugs are logged to output instead of Slack
56 changes: 34 additions & 22 deletions cmd/doctext/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
const queryTriaged = query.ShiftStack + `AND status in ("Release Pending", Verified, ON_QA) AND "Release Note Text" is EMPTY`

var (
BUGWATCHER_DEBUG = os.Getenv("BUGWATCHER_DEBUG")
SLACK_HOOK = os.Getenv("SLACK_HOOK")
JIRA_TOKEN = os.Getenv("JIRA_TOKEN")
TEAM_MEMBERS_DICT = os.Getenv("TEAM_MEMBERS_DICT")
Expand All @@ -23,11 +24,6 @@ var (
func main() {
ctx := context.Background()

var team Team
if err := team.Load(strings.NewReader(TEAM_MEMBERS_DICT)); err != nil {
log.Fatalf("error unmarshaling TEAM_MEMBERS_DICT: %v", err)
}

var jiraClient *jira.Client
{
var err error
Expand All @@ -49,7 +45,6 @@ func main() {
gotErrors bool
wg sync.WaitGroup
)
slackClient := &http.Client{}
issues := make(map[string][]jira.Issue)
for issue := range searchIssues(ctx, jiraClient, queryTriaged) {
wg.Add(1)
Expand Down Expand Up @@ -84,15 +79,30 @@ func main() {
}
wg.Wait()

for assignee, issue := range issues {
teamMember, ok := team[assignee]
if !ok {
teamMember = team["team"]
if BUGWATCHER_DEBUG == "" {
var team Team
if err := team.Load(strings.NewReader(TEAM_MEMBERS_DICT)); err != nil {
log.Fatalf("error unmarshaling TEAM_MEMBERS_DICT: %v", err)
}
if err := notify(SLACK_HOOK, slackClient, issue, teamMember); err != nil {
gotErrors = true
log.Print(err)
return

slackClient := &http.Client{}
for assignee, issue := range issues {
teamMember, ok := team[assignee]
if !ok {
teamMember = team["team"]
}
if err := notify(SLACK_HOOK, slackClient, issue, teamMember); err != nil {
gotErrors = true
log.Print(err)
return
}
}
} else {
for assignee, issue := range issues {
log.Printf("Found %d issues for assignee %s", len(issue), assignee)
for _, x := range issue {
log.Printf("- %s (%s)", x.Key, x.Fields.Summary)
}
}
}

Expand All @@ -105,19 +115,21 @@ func main() {

func init() {
ex_usage := false
if SLACK_HOOK == "" {
ex_usage = true
log.Print("Required environment variable not found: SLACK_HOOK")
}

if JIRA_TOKEN == "" {
ex_usage = true
log.Print("Required environment variable not found: JIRA_TOKEN")
}

if TEAM_MEMBERS_DICT == "" {
ex_usage = true
log.Print("Required environment variable not found: TEAM_MEMBERS_DICT")
if BUGWATCHER_DEBUG == "" {
if SLACK_HOOK == "" {
ex_usage = true
log.Print("Required environment variable not found: SLACK_HOOK")
}

if TEAM_MEMBERS_DICT == "" {
ex_usage = true
log.Print("Required environment variable not found: TEAM_MEMBERS_DICT")
}
}

if ex_usage {
Expand Down