@@ -15,6 +15,7 @@ type JiraClient struct {
15
15
config map [string ]string
16
16
}
17
17
18
+ // Create will create a new client
18
19
func (j * JiraClient ) Create () (string , error ) {
19
20
domain , err := j .GetDomain ()
20
21
@@ -63,9 +64,7 @@ func GetIssueID(branchName string) string {
63
64
64
65
// Comment : Post a comment on a jira issue
65
66
func (j * JiraClient ) Comment (branchName , comment string ) error {
66
- fmt .Println (branchName )
67
67
issueID := GetIssueID (branchName )
68
- fmt .Println (issueID )
69
68
70
69
jiraComment := & jira.Comment {
71
70
Body : comment ,
@@ -75,6 +74,7 @@ func (j *JiraClient) Comment(branchName, comment string) error {
75
74
return err
76
75
}
77
76
77
+ // GetDomain : Get the domain from the config
78
78
func (j * JiraClient ) GetDomain () (string , error ) {
79
79
80
80
domain , ok := j .config ["domain" ]
@@ -130,27 +130,18 @@ func indexOf(status string, data []string) int {
130
130
func (j * JiraClient ) Start (issueType string , issueID string ) (string , error ) {
131
131
allowed := strings .Split (j .config ["transitions" ], "," )
132
132
133
- fmt .Println (issueID )
134
-
135
133
transitions , response , err := j .client .Issue .GetTransitions (issueID )
136
- fmt .Println (transitions )
137
-
138
- if err != nil {
139
- fmt .Println (err )
140
- fmt .Println (response .Body )
141
- return "" , err
142
- }
143
-
144
- nextTransition := transitions [0 ]
145
134
146
- if indexOf (nextTransition .Name , allowed ) > - 1 {
147
- _ , err := j .client .Issue .DoTransition (issueID , nextTransition .ID )
135
+ for _ , transition := range transitions {
136
+ if indexOf (transition .Name , allowed ) > - 1 {
137
+ _ , err := j .client .Issue .DoTransition (issueID , transition .ID )
148
138
149
- if err != nil {
150
- return "" , err
139
+ if err != nil {
140
+ fmt .Println (err )
141
+ fmt .Println (response .Body )
142
+ return "" , err
143
+ }
151
144
}
152
-
153
- _ , _ = j .Start (issueType , issueID )
154
145
}
155
146
156
147
branchName , err := j .GetBranchName (issueType , issueID )
@@ -167,7 +158,6 @@ func (j *JiraClient) FormatField(fieldName string, value string) string {
167
158
if fieldName == "domain" {
168
159
return fmt .Sprintf ("https://%s" , value )
169
160
}
170
-
171
161
return value
172
162
}
173
163
@@ -184,15 +174,14 @@ func (j *JiraClient) GetAuthFields() map[string]bool {
184
174
185
175
// Authenticate : Authenticates using the fields passed in
186
176
func (j * JiraClient ) Authenticate (fields map [string ]string ) bool {
187
- jiraClient , err := jira .NewClient (nil , fields ["domain" ])
188
-
189
- if err != nil {
190
- return false
177
+ tp := jira.BasicAuthTransport {
178
+ Username : fields ["username" ],
179
+ Password : fields ["password" ],
191
180
}
192
181
193
- res , err := jiraClient . Authentication . AcquireSessionCookie ( fields [ "username" ] , fields ["password " ])
182
+ jiraClient , err := jira . NewClient ( tp . Client () , fields ["domain " ])
194
183
195
- if err != nil || res == false {
184
+ if err != nil {
196
185
return false
197
186
}
198
187
0 commit comments