Skip to content

Commit

Permalink
support direct value jira fields (#85)
Browse files Browse the repository at this point in the history
* support direct value jira fields

* minor docs update

* linting
  • Loading branch information
northdpole committed Jan 4, 2021
1 parent 948344d commit c11ef14
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions common/jira/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,30 @@ defaultValues:
# - id: 'customfield_10050'
# fieldType: single-value
# values: ['Foo']
# translates to jira api as "customfield_10050":{"value":"Foo"}

## This example will fill in the customfield_10050, a multi-value field, with the value 'Foo' and 'Bar'
# - id: 'customfield_10050'
# fieldType: multi-value
# values: ['Foo', 'Bar']

## This example will fill in the customfield_10050, a float value field, with the number 55.3
## This example will fill in the customfield_10050, a float value field, with the number 55.3
# - id: 'customfield_10050'
# fieldType: float
# values: ['55.3'] # Note, this is still specified as a string input

## More explanation on fieldTypes:
## This example will fill in the customfield_10050, a "simple" value field, with the value 'Foo'
# - id: 'customfield_10050'
# fieldType: simple-value
# values: ['Foo']
# this translates to jira api as "customfield_10050": "Foo"

## More explanation on fieldTypes:
## single-value: can only be populated by one value (e.g. Project Key)
## multi-value: can be populated by multiple values (e.g. Components)
## float: can be populated by only one numeric value (e.g. CVSS)
## simple-value: will translate to the special jira use case of "customfield_id":"value"
## simple-value is provided as a workaround when single-value does not work with your jira setup

## Uncomment the fields you want included in the Issue's Description
addToDescription:
Expand Down
2 changes: 2 additions & 0 deletions common/jira/jira/apiutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func makeCustomField(fieldType string, values []string) interface{} {
} else {
log.Fatalf("Error parsing float field-type: %v", err)
}
case "simple-value":
return values[0]
default:
log.Printf("Warning: Field type %s is not supported. Edit your config.yaml file, as this field will not be displayed correctly.", fieldType)
return nil
Expand Down
4 changes: 4 additions & 0 deletions common/jira/jira/apiutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ func TestMakeCustomField(t *testing.T) {
res3 := makeCustomField("float", []string{"4.22"})
exp3 := 4.22

res4 := makeCustomField("simple-value",[]string{"test-value"})
exp4 := "test-value"

assert.EqualValues(t, res1, exp1)
assert.EqualValues(t, res2, exp2)
assert.Equal(t, res3, exp3)
assert.Equal(t, res4, exp4)
}

func TestMakeDescription(t *testing.T) {
Expand Down

0 comments on commit c11ef14

Please sign in to comment.