@@ -173,6 +173,49 @@ func main() {
173173}
174174```
175175
176+ ### Change an issue status
177+
178+ This is how one can change an issue status. In this example, we change the issue from "To Do" to "In Progress."
179+
180+ ``` go
181+ package main
182+
183+ import (
184+ " fmt"
185+ " github.com/andygrunwald/go-jira"
186+ )
187+
188+ func main () {
189+ base := " https://my.jira.com"
190+ tp := jira.BasicAuthTransport {
191+ Username: " username" ,
192+ Password: " token" ,
193+ }
194+
195+ jiraClient , err := jira.NewClient (tp.Client (), base)
196+ if err != nil {
197+ panic (err)
198+ }
199+
200+ issue , _ , _ := jiraClient.Issue .Get (" FART-1" , nil )
201+ currentStatus := issue.Fields .Status .Name
202+ fmt.Printf (" Current status: %s \n " , currentStatus)
203+
204+ var transitionID string
205+ possibleTransitions , _ , _ := jiraClient.Issue .GetTransitions (" FART-1" )
206+ for _ , v := range possibleTransitions {
207+ if v.Name == " In Progress" {
208+ transitionID = v.ID
209+ break
210+ }
211+ }
212+
213+ jiraClient.Issue .DoTransition (" FART-1" , transitionID)
214+ issue, _, _ = jiraClient.Issue .Get (testIssueID, nil )
215+ fmt.Printf (" Status after transition: %+v \n " , issue.Fields .Status .Name )
216+ }
217+ ```
218+
176219### Call a not implemented API endpoint
177220
178221Not all API endpoints of the Jira API are implemented into * go-jira* .
0 commit comments