Skip to content

Commit 1a748c8

Browse files
committed
Add flags for jira service
1 parent a55bf45 commit 1a748c8

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

gitlab/resource_gitlab_service_jira.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ func resourceGitlabServiceJira() *schema.Resource {
6363
Type: schema.TypeString,
6464
Optional: true,
6565
},
66+
"commit_events": {
67+
Type: schema.TypeBool,
68+
Optional: true,
69+
Computed: true,
70+
},
71+
"merge_requests_events": {
72+
Type: schema.TypeBool,
73+
Optional: true,
74+
Computed: true,
75+
},
76+
"comment_on_event_enabled": {
77+
Type: schema.TypeBool,
78+
Optional: true,
79+
Computed: true,
80+
},
6681
},
6782
}
6883
}
@@ -119,7 +134,9 @@ func resourceGitlabServiceJiraRead(d *schema.ResourceData, meta interface{}) err
119134
d.Set("active", jiraService.Active)
120135
d.Set("push_events", jiraService.PushEvents)
121136
d.Set("issues_events", jiraService.IssuesEvents)
137+
d.Set("commit_events", jiraService.CommitEvents)
122138
d.Set("merge_requests_events", jiraService.MergeRequestsEvents)
139+
d.Set("comment_on_event_enabled", jiraService.CommentOnEventEnabled)
123140
d.Set("tag_push_events", jiraService.TagPushEvents)
124141
d.Set("note_events", jiraService.NoteEvents)
125142
d.Set("pipeline_events", jiraService.PipelineEvents)
@@ -152,6 +169,9 @@ func expandJiraOptions(d *schema.ResourceData) (*gitlab.SetJiraServiceOptions, e
152169
setJiraServiceOptions.ProjectKey = gitlab.String(d.Get("project_key").(string))
153170
setJiraServiceOptions.Username = gitlab.String(d.Get("username").(string))
154171
setJiraServiceOptions.Password = gitlab.String(d.Get("password").(string))
172+
setJiraServiceOptions.CommitEvents = gitlab.Bool(d.Get("commit_events").(bool))
173+
setJiraServiceOptions.MergeRequestsEvents = gitlab.Bool(d.Get("merge_requests_events").(bool))
174+
setJiraServiceOptions.CommentOnEventEnabled = gitlab.Bool(d.Get("comment_on_event_enabled").(bool))
155175

156176
// Set optional properties
157177
if val := d.Get("jira_issue_transition_id"); val != nil {

gitlab/resource_gitlab_service_jira_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
2828
resource.TestCheckResourceAttr(jiraResourceName, "url", "https://test.com"),
2929
resource.TestCheckResourceAttr(jiraResourceName, "username", "user1"),
3030
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass"),
31+
resource.TestCheckResourceAttr(jiraResourceName, "commit_events", "true"),
32+
resource.TestCheckResourceAttr(jiraResourceName, "merge_requests_events", "false"),
33+
resource.TestCheckResourceAttr(jiraResourceName, "comment_on_event_enabled", "false"),
3134
),
3235
},
3336
// Update the jira service
@@ -39,6 +42,9 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
3942
resource.TestCheckResourceAttr(jiraResourceName, "username", "user2"),
4043
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass_update"),
4144
resource.TestCheckResourceAttr(jiraResourceName, "jira_issue_transition_id", "3"),
45+
resource.TestCheckResourceAttr(jiraResourceName, "commit_events", "false"),
46+
resource.TestCheckResourceAttr(jiraResourceName, "merge_requests_events", "true"),
47+
resource.TestCheckResourceAttr(jiraResourceName, "comment_on_event_enabled", "true"),
4248
),
4349
},
4450
// Update the jira service to get back to previous settings
@@ -49,6 +55,9 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
4955
resource.TestCheckResourceAttr(jiraResourceName, "url", "https://test.com"),
5056
resource.TestCheckResourceAttr(jiraResourceName, "username", "user1"),
5157
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass"),
58+
resource.TestCheckResourceAttr(jiraResourceName, "commit_events", "true"),
59+
resource.TestCheckResourceAttr(jiraResourceName, "merge_requests_events", "false"),
60+
resource.TestCheckResourceAttr(jiraResourceName, "comment_on_event_enabled", "false"),
5261
),
5362
},
5463
},
@@ -158,6 +167,9 @@ resource "gitlab_service_jira" "jira" {
158167
url = "https://test.com"
159168
username = "user1"
160169
password = "mypass"
170+
commit_events = true
171+
merge_requests_events = false
172+
comment_on_event_enabled = false
161173
}
162174
`, rInt)
163175
}
@@ -178,6 +190,9 @@ resource "gitlab_service_jira" "jira" {
178190
username = "user2"
179191
password = "mypass_update"
180192
jira_issue_transition_id = "3"
193+
commit_events = false
194+
merge_requests_events = true
195+
comment_on_event_enabled = true
181196
}
182197
`, rInt)
183198
}

website/docs/r/service_jira.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ The following arguments are supported:
4343

4444
* `jira_issue_transition_id` - (Optional) The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (Administration > Issues > Workflows) by selecting View under Operations of the desired workflow of your project. By default, this ID is set to 2.
4545

46+
* `commit_events` - (Optional) Enable notifications for commit events
47+
48+
* `merge_requests_events` - (Optional) Enable notifications for merge request events
49+
50+
* `comment_on_event_enabled` - (Optional) Enable comments inside Jira issues on each GitLab event (commit / merge request)
51+
4652
## Importing Jira service
4753

4854
You can import a service_jira state using `terraform import <resource> <project_id>`:

0 commit comments

Comments
 (0)