PoshCode Archive  Artifact Content

Artifact 59279c69c44a4ccb3833353517ff0c244b7cb1ef23eed1c2b9de90f475327d24:

  • File The-following-powershell-code-allows-.ps1 — part of check-in [b66437c264] at 2018-06-10 13:58:19 on branch trunk — The following powershell code allows you to log into jira, create an issue, assign the issue to someone (yourself in this case), add two comments, resolve, and close. (user: unknown size: 2929)

# encoding: ascii
# api: powershell
# title: 
# description: The following powershell code allows you to log into jira, create an issue, assign the issue to someone (yourself in this case), add two comments, resolve, and close.
# version: 0.1
# type: script
# license: CC0
# x-poshcode-id: 5639
# x-archived: 2015-02-17T21:43:42
#
#

# see http://poshcode.org/751

$jirasvc = New-WebServiceProxy -Uri "http://jra.netpost/jira//rpc/soap/jirasoapservice-v2?wsdl"
$username = "myuserid"
$password = "mypassword"

# login ###################################################################################
$token = $jirasvc.login($username,$password)

$namespace = $jirasvc.GetType().Namespace

# create a new issue ######################################################################
$issue = New-Object "$namespace.RemoteIssue"

$Jira_Component = New-Object "$namespace.RemoteComponent"
$Jira_Component.id = 12740
$Jira_Component.name = "SCM" 
 
$issue.summary = "a summary" 
$issue.description = "foo mane padme hum" 
$issue.type = "3" #Task
$issue.priority = "4" #Minor
$issue.components += $Jira_Component 
$issue.project = "TEST"

# create the issue issue 
$remoteIssue = $jirasvc.createIssue($token,$issue)

# show the new issue number 
Write-Host $remoteIssue.key

# assign to me ############################################################################
# to change the assignee, we need a remoteField 
$remoteField = New-Object "$namespace.RemoteFieldValue"
$remoteField.id = "assignee"
$remoteField.values = @( "laenenj" ) 

# assign to me 
$remoteIssue = $jirasvc.updateIssue($token,$remoteIssue.key, $remoteField)

# start working ###########################################################################
$startWorking = New-Object "$namespace.RemoteFieldValue"
$startWorking.id = "Start working"
 
$remoteIssue = $jirasvc.progressWorkflowAction($token,$remoteIssue.key,"751",$startWorking)

# add a comment ###########################################################################
$remoteComment = New-Object "$namespace.RemoteComment"
$remoteComment.body = "A first comment"
$jirasvc.addComment($token,$remoteIssue.key,$remoteComment)

# add a second comment ####################################################################
$remoteComment.body = "A second comment"
$jirasvc.addComment($token,$remoteIssue.key,$remoteComment)

# resolve #################################################################################
$resolve = New-Object "$namespace.RemoteFieldValue"
$resolve.id = "Finish"
 
$remoteIssue = $jirasvc.progressWorkflowAction($token,$remoteIssue.key,"5",$resolve)

# close ###################################################################################
$close = New-Object "$namespace.RemoteFieldValue"
$close.id = "Close"
 
$remoteIssue = $jirasvc.progressWorkflowAction($token,$remoteIssue.key,"2",$close)