View/Download jiraFunctions.ps1 Script
Atlassian Jira is a web-based bug/issue tracking software, but lucky for us, they provide a WSDL interface so that we can access it from a Powershell command line.
This script is only successful because of the work of Lee Holmes’ connect-wsdl function. I’ve included it as part of this script for convenience.
First you will need to edit the $jiraURL variable in the script so that it points to your Jira WSDL URL. I usually initialize most of my functions (and some variables) globally to make things easier, so after you’ve made the necessary edit, just run it from a command line. The script will prompt you for a login/password for Jira.
Note: Some functions are incomplete/untested, so be sure to test before using in a production environment!
Connect-Jira is the first function that is called, and it establishes an initial connection to the Jira webservice. This is the function that uses Lee’s connect-webservice function (and I honestly don’t know enough C# to understand how it works).
$global:jira = connect-jira $jiraURL
After the connection is established, you are authenticated to Jira securely using a login/password. Thanks to Joel Bennett for the clever bits of code to securely grab the password without storing it anywhere. There is a session ID stored in the $jiraAuthID variable that is used to identify your session. A valid $jiraAuthID must be passed to most functions for them to succeed. If the ID has timed out, the function calls will fail.
$BSTR = [System.Runtime.InteropServices.marshal]::SecureStringToBSTR($credential.Password) $global:jiraAuthID = $jira.login($credential.UserName.TrimStart("\"),[System.Runtime.InteropServices.marshal]::PtrToStringAuto($BSTR)) [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($BSTR);
At this point, you are dropped back to the Powershell prompt where you can call the many functions available to you. For example:
PS C:\scripts\jira> get-jiraserverinfo baseUrl : https://server.yourdomain.com/jira buildDate : 9/13/2006 4:00:00 AM buildNumber : 161 edition : Enterprise version : 3.6.5
PS C:\scripts\jira> get-jiraresolution description icon name id ----------- ---- ---- -- A fix for this issue is ch... Fixed 1 The problem described is a... Won't Fix 2 The problem is a duplicate... Duplicate 3 The problem is not complet... Incomplete 4 All attempts at reproducin... Cannot Reproduce 5 The bug report describes b... NOTABUG 6 Issue type was a general q... Issue Closed 7
PS C:\scripts\jira> get-jiraissue "WIN-113" affectsVersions : {} assignee : rfoust attachmentNames : {} components : {} created : 7/11/2008 9:12:48 PM customFieldValues : {} description : Create an altiris job to push out this script/command to all windows servers. There's a bug in the powershell installer so this doesn't get done. When complete, powershell will start up *much* fas ter. In fact, thats almost an understatement. :) Set-Alias ngen @( dir (join-path ${env:\windir} "Microsoft.NET\Framework") ngen.exe -recurse | sort -descending lastwritetime )[0].fullName [appdomain]::currentdomain.getassemblies() | %{ngen $_.location} For more info, see: http://blogs.msdn.com/powershell/archive/2007/11/08/update-gac-ps1.aspx duedate : environment : fixVersions : {} key : WIN-113 priority : 4 project : WIN reporter : rfoust resolution : status : 1 summary : Update GAC on all servers to decrease powershell startup time type : 4 updated : 7/23/2008 1:40:17 PM votes : 0 id : 20685
Enjoy! :)
- Robbie

