Trying to transition Issues in Jira Automatically with Octopus Deploy Run a Script (Powershell)

I am trying to build a process that will allow us to Schedule our Release and the first step will be to change the Jira Issue/Ticket transitions.

I keep getting an error stating “New-Object : Cannot find an overload for “PSCredential” and the argument count: “2”.”

This is the Code I am using Below

$username=#{JiraUserName}
$password=#{JiraPassword}
$Credentials = New-Object System.Management.Automation.PSCredential $username, $password
Install-Module JiraPS -Scope CurrentUser
Update-Module JiraPS
Import-Module JiraPS
Set-JiraConfigServer ‘https://Jira.Company.Com
New-JiraSession -Credential $Credentials
Get-JiraIssue “CAA-137” | Invoke-JiraIssueTransition -transition 11#

Any help would be tremendous.

We are “on Prem” Jira

Hi @A-Sedler,

Thanks for getting in touch with Octopus and your question!

This looks primarily like a PowerShell syntax-type issue rather than something specific in Octopus.

I’ve not used the JiraPS PowerShell module myself, but I think the issue you are getting is that the PSCredential object is expecting a password that is a type of SecureString rather than just a String.

Instead of what you have I’d recommend something like this:

$username="#{JiraUserName}"
$password="#{JiraPassword}"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential $username, $securePassword

# Rest of script omitted...

Just a quick note: I also added double quotes to the username and password variables, which may or may not be needed for your use case.

I hope that helps!

Best,

1 Like

Thank you, this was a big help in my progress.

Hi @A-Sedler

That’s great to hear.

Happy deployments!

Best,