-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a1eb06
Showing
15 changed files
with
6,715 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "@atlassian-partner-engineering", | ||
"rules": { | ||
"no-plusplus": "off" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM node:10-alpine | ||
|
||
LABEL "name"="Jira Create" | ||
LABEL "maintainer"="Dima Rudzik <drudzik+githubactions@atlassian.net>" | ||
LABEL "version"="1.0.0" | ||
|
||
LABEL "com.github.actions.name"="Jira Create" | ||
LABEL "com.github.actions.description"="Create a new Jira issue" | ||
LABEL "com.github.actions.icon"="check-square" | ||
LABEL "com.github.actions.color"="blue" | ||
|
||
RUN apk update && apk add --no-cache ca-certificates | ||
|
||
ADD https://github.com/atlassian/gajira/raw/master/bin/gagas . | ||
ADD . . | ||
RUN npm i | ||
RUN chmod +x /entrypoint.sh | ||
RUN chmod +x /test.sh | ||
RUN chmod +x /gagas | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Jira Create | ||
Create new issue | ||
|
||
## Usage | ||
|
||
TBD | ||
|
||
---- | ||
## Action Spec: | ||
|
||
### Environment variables | ||
- None | ||
|
||
### Arguments | ||
- `--project=<project key>` - Key of the project | ||
- `--issuetype=<issue type>` - Type of the issue to be created. Example: 'Incident' | ||
- `--summary=<text>` - Issue summary | ||
- `--description=<text>` - Issue description | ||
- `--fields.customfield_<number>.id=<custom field id>` - ID of the custom field. Example `--fields.customfield_10021.id=10001` | ||
|
||
### Reads fields from config file at $HOME/jira/config.yml | ||
- `project` | ||
- `issuetype` | ||
- `summary` | ||
- `description` | ||
|
||
### Writes fields to config file at $HOME/jira/config.yml | ||
- `issue` - a key of a newly created issue | ||
|
||
### Writes fields to CLI config file at $HOME/.jira.d/config.yml | ||
- `issue` - a key of a newly created issue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
const nock = require('nock') | ||
const Action = require('../action') | ||
|
||
const auth = { email: 'test@email.com', token: 'tokentoken' } | ||
const baseUrl = 'https://example.com' | ||
const config = { | ||
...auth, | ||
baseUrl, | ||
} | ||
|
||
const projectKey = 'TESTPROJECT' | ||
const issuetypeName = 'TESTISSUETYPE' | ||
|
||
const { mocks } = require('./helpers') | ||
|
||
test(`Should create simple issue with interpolated event field in summary and description`, async () => { | ||
const action = new Action({ | ||
githubEvent: { | ||
ref: 'ref/head/blah', | ||
}, | ||
argv: { | ||
project: projectKey, | ||
issuetype: issuetypeName, | ||
summary: 'This is summary {{ event.ref }}', | ||
description: 'This is description {{ event.ref }}', | ||
}, | ||
config, | ||
}) | ||
|
||
const createMetaRequest = nock(baseUrl) | ||
.get('/rest/api/2/issue/createmeta') | ||
.query({ | ||
expand: 'projects.issuetypes.fields', | ||
projectKeys: 'TESTPROJECT', | ||
issuetypeNames: 'TESTISSUETYPE', | ||
}) | ||
.reply(200, mocks.jira.responses.createMeta) | ||
|
||
let createIssueRequestBody = {} | ||
const createIssueRequest = nock(baseUrl) | ||
.post('/rest/api/2/issue') | ||
.reply(200, (url, body) => { | ||
createIssueRequestBody = body | ||
|
||
return { | ||
key: 'TESTPROJECT-2', | ||
} | ||
}) | ||
|
||
await createMetaRequest | ||
await createIssueRequest | ||
|
||
const result = await action.execute() | ||
|
||
expect(createIssueRequestBody).toEqual({ | ||
fields: { | ||
project: { | ||
key: projectKey, | ||
}, | ||
issuetype: { | ||
name: issuetypeName, | ||
}, | ||
summary: 'This is summary ref/head/blah', | ||
description: 'This is description ref/head/blah', | ||
}, | ||
}) | ||
|
||
expect(result).toEqual({ | ||
issue: 'TESTPROJECT-2', | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable global-require */ | ||
|
||
module.exports = { | ||
mocks: require('./mocks'), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const requireDirectory = require('require-directory') | ||
|
||
module.exports = requireDirectory(module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
{ | ||
"projects": [{ | ||
"issuetypes": [{ | ||
"fields": { | ||
"summary": { | ||
"required": true, | ||
"schema": { | ||
"type": "string", | ||
"system": "summary" | ||
}, | ||
"name": "Summary", | ||
"key": "summary", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"set" | ||
] | ||
}, | ||
"issuetype": { | ||
"required": true, | ||
"schema": { | ||
"type": "issuetype", | ||
"system": "issuetype" | ||
}, | ||
"name": "Issue Type", | ||
"key": "issuetype", | ||
"hasDefaultValue": false, | ||
"operations": [], | ||
"allowedValues": [{ | ||
"self": "https://example.com/rest/api/2/issuetype/10002", | ||
"id": "10002", | ||
"description": "An event that causes disruption to or a reduction in the quality of a service which requires an emergency response", | ||
"iconUrl": "https://example.com/secure/viewavatar?size=xsmall&avatarId=10308&avatarType=issuetype", | ||
"name": "Incident", | ||
"subtask": false, | ||
"avatarId": 10308 | ||
}] | ||
}, | ||
"attachment": { | ||
"required": false, | ||
"schema": { | ||
"type": "array", | ||
"items": "attachment", | ||
"system": "attachment" | ||
}, | ||
"name": "Attachment", | ||
"key": "attachment", | ||
"hasDefaultValue": false, | ||
"operations": [] | ||
}, | ||
"description": { | ||
"required": false, | ||
"schema": { | ||
"type": "string", | ||
"system": "description" | ||
}, | ||
"name": "Description", | ||
"key": "description", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"set" | ||
] | ||
}, | ||
"project": { | ||
"required": true, | ||
"schema": { | ||
"type": "project", | ||
"system": "project" | ||
}, | ||
"name": "Project", | ||
"key": "project", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"set" | ||
], | ||
"allowedValues": [{ | ||
"self": "https://example.com/rest/api/2/project/10000", | ||
"id": "10000", | ||
"key": "INC", | ||
"name": "Incidents", | ||
"projectTypeKey": "ops", | ||
"avatarUrls": { | ||
"48x48": "https://example.com/secure/projectavatar?avatarId=10324", | ||
"24x24": "https://example.com/secure/projectavatar?size=small&avatarId=10324", | ||
"16x16": "https://example.com/secure/projectavatar?size=xsmall&avatarId=10324", | ||
"32x32": "https://example.com/secure/projectavatar?size=medium&avatarId=10324" | ||
} | ||
}] | ||
}, | ||
"customfield_10021": { | ||
"required": true, | ||
"schema": { | ||
"type": "option", | ||
"custom": "com.atlassian.jira.jira-incident-management-plugin:incident-severity", | ||
"customId": 10021 | ||
}, | ||
"name": "Severity", | ||
"key": "customfield_10021", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"set" | ||
], | ||
"allowedValues": [{ | ||
"id": "10001", | ||
"value": "1 - Critical", | ||
"position": 1, | ||
"iconUrl": "https://example.com/images/icons/ops/severities/Critical.svg" | ||
}, | ||
{ | ||
"id": "10002", | ||
"value": "2 - High", | ||
"position": 2, | ||
"iconUrl": "https://example.com/images/icons/ops/severities/High.svg" | ||
}, | ||
{ | ||
"id": "10000", | ||
"value": "3 - Moderate", | ||
"position": 3, | ||
"iconUrl": "https://example.com/images/icons/ops/severities/Moderate.svg" | ||
}, | ||
{ | ||
"id": "10008", | ||
"value": "4 - Low", | ||
"position": 4, | ||
"iconUrl": "https://example.com/images/icons/ops/severities/Low.svg" | ||
}, | ||
{ | ||
"id": "10009", | ||
"value": "5 - Informational", | ||
"position": 5, | ||
"iconUrl": "https://example.com/images/icons/ops/severities/Informational.svg" | ||
} | ||
] | ||
}, | ||
"issuelinks": { | ||
"required": false, | ||
"schema": { | ||
"type": "array", | ||
"items": "issuelinks", | ||
"system": "issuelinks" | ||
}, | ||
"name": "Linked Issues", | ||
"key": "issuelinks", | ||
"autoCompleteUrl": "https://example.com/rest/api/2/issue/picker?currentProjectId=&showSubTaskParent=true&showSubTasks=true¤tIssueKey=null&query=", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"add" | ||
] | ||
}, | ||
"reporter": { | ||
"required": true, | ||
"schema": { | ||
"type": "user", | ||
"system": "reporter" | ||
}, | ||
"name": "Reporter", | ||
"key": "reporter", | ||
"autoCompleteUrl": "https://example.com/rest/api/latest/user/search?query=", | ||
"hasDefaultValue": true, | ||
"operations": [ | ||
"set" | ||
] | ||
}, | ||
"customfield_10022": { | ||
"required": false, | ||
"schema": { | ||
"type": "array", | ||
"items": "im-affected-services", | ||
"custom": "com.atlassian.jira.jira-incident-management-plugin:affected-services", | ||
"customId": 10022 | ||
}, | ||
"name": "Affected services", | ||
"key": "customfield_10022", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"add", | ||
"set", | ||
"remove" | ||
], | ||
"allowedValues": [] | ||
}, | ||
"assignee": { | ||
"required": false, | ||
"schema": { | ||
"type": "user", | ||
"system": "assignee" | ||
}, | ||
"name": "Assignee", | ||
"key": "assignee", | ||
"autoCompleteUrl": "https://example.com/rest/api/latest/user/assignable/search?project=INC&query=", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"set" | ||
] | ||
}, | ||
"labels": { | ||
"required": false, | ||
"schema": { | ||
"type": "array", | ||
"items": "string", | ||
"system": "labels" | ||
}, | ||
"name": "Labels", | ||
"key": "labels", | ||
"autoCompleteUrl": "https://example.com/rest/api/1.0/labels/suggest?query=", | ||
"hasDefaultValue": false, | ||
"operations": [ | ||
"add", | ||
"set", | ||
"remove" | ||
] | ||
} | ||
} | ||
}] | ||
}] | ||
} |
Oops, something went wrong.