Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

create project version url

Angelo Diego Crabolu February 25, 2013

Can I use powershell to "call" an url on jira to create a version for a project?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Angelo Diego Crabolu March 5, 2013
here is a powershell cmd to do that

[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True, Position=1)]
  [string]$project,
  [Parameter(Mandatory=$True, Position=2)]
  [string]$newVersionName,
  [Parameter(Mandatory=$True, Position=3)]
  [string]$newVersionDesc
 )

function ConvertTo-Base64($string) {
   $bytes  = [System.Text.Encoding]::UTF8.GetBytes($string);
   $encoded = [System.Convert]::ToBase64String($bytes);

   return $encoded;
}

function Get-HttpBasicHeader([string]$username, [string]$password, $Headers = @{})
{
 	$b64 = ConvertTo-Base64 "$($username):$($Password)"
	$Headers["Authorization"] = "Basic $b64"
	return $Headers
}

$restapiuri = "http://yourserver/rest/api/2/"
$headers = Get-HttpBasicHeader "yourusername" "yourpass"

function CreateVersion
{
    $jsonReponse = Invoke-RestMethod -uri ($restapiuri +"project/"+$project+"/versions") -Headers $headers -Method Get -ContentType "application/json"
    #create new version
    $body = ('{"name": "' + $newVersionName +'", "description": "'+ $newVersionDesc+'",  "project": "' + $project +'"}')
    Invoke-RestMethod -uri ($restapiuri +"version/") -Headers $headers -Method POST -ContentType "application/json" -Body $body
}

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2013

You can use JIRA Command Line Interface, specifically addVersion action.

TAGS
AUG Leaders

Atlassian Community Events