Skip to content

Instantly share code, notes, and snippets.

@ku
Created October 28, 2014 04:09
Show Gist options
  • Select an option

  • Save ku/7a8cd89be3ee8f5c7ac9 to your computer and use it in GitHub Desktop.

Select an option

Save ku/7a8cd89be3ee8f5c7ac9 to your computer and use it in GitHub Desktop.
ticketmachine
#!/usr/bin/env coffee
#
JiraApi = require('jira').JiraApi
#process = require 'process'
exec = require('child_process').exec
if process.argv.length < 1 + 2
console.log "usage: ticketmachine sumamry [description]"
return 1
[summary, description] = process.argv.slice 2
# https://sourcegraph.com/github.com/tebriel/jira-cli/tree/267b76ecf872d380532eea74d6cf4550597471e9/lib/jira-cli.js
createIssueObject = (project, summary, issueType, description) ->
return {
fields: {
project: {
id: project
},
summary: summary,
issuetype: {
id: issueType
},
reporter: {
name: 'ku'
},
assignee: {
name: 'ku'
},
description: description
}
}
jira = new JiraApi(
'https',
'*****.atlassian.net',
null,
'USER',
'PASSWD',
'2',
true
)
#jira.listProjects (err, r) ->
# console.log r
# r.map (t) ->
# console.log t.name
#jira.listIssueTypes (err, r) ->
# r.map (t) ->
# console.log t
project = 10103 # PBCD
#issueType = 3 #'Task'
issueType = 1 #Bug
newIssue = createIssueObject(project, summary, issueType, description)
jira.addNewIssue newIssue, (err, r) ->
console.log r
branch = "#{r.key} #{summary}".replace(/\ /g, '-')
exec "git checkout -b #{branch}", (error, stdout, stderr) ->
# do nothing
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment