atlassianps / jiraps Goto Github PK
View Code? Open in Web Editor NEWPowerShell module to interact with Atlassian JIRA
Home Page: https://AtlassianPS.org/module/JiraPS
License: MIT License
PowerShell module to interact with Atlassian JIRA
Home Page: https://AtlassianPS.org/module/JiraPS
License: MIT License
Hello,
New-JiraIssue -Project SSC -IssueType Incident -Priority 1 -Reporter 'Lucie' -Summary 'Test issue from PowerShell' -Description 'This is a test issue created from the PSJira module in PowerShell.' -Fields @{
'customfield_10482'='10413';
}
WARNING: JIRA returned HTTP error 400 - BadRequest
Resolve-JiraError : Jira encountered an error: [customfield_10482] - Could not find valid 'id' or 'value' in the Parent
Option object.
and without custom field :
WARNING: JIRA returned HTTP error 400 - BadRequest
Resolve-JiraError : Jira encountered an error: [Service_Support is required.]
Its a multi select item : When i run :
Get-JiraIssueCreateMetadata -Project SSC -IssueType Incident
Id : customfield_10482
Name : Service_Support
Schema : @{type=option; custom=com.atlassian.jira.plugin.system.customfieldtypes:select; customId=10482}
HasDefaultValue : False
Required : False
AllowedValues : {@{self=http://jira:8080/rest/api/2/customFieldOption/10414; value=Cellule Metier; id=10414},
@{self=http://jira:8080/rest/api/2/customFieldOption/10610; value=Cellule BI; id=10610},
@{self=http://jira:8080/rest/api/2/customFieldOption/10413; value=Service Client; id=10413},
@{self=http://jira:8080/rest/api/2/customFieldOption/10415; value=Cellule Infrastructure; id=10415}}
Operations : set
Could you help how to select this particular value with customfields.
Thanks for your help,
It looks like an additional authentication must be performed in order for WebSudo rights to be granted on the JiraSession.
Issue does not appear if WebSudo is disabled.
PS C:\WINDOWS\system32> New-JiraUser -UserName "jdoe" -DisplayName "John Doe" -EmailAddress "[email protected]" -Notify $False
WARNING: JIRA returned HTTP error 401 - Unauthorized
ConvertFrom-Json2 : Cannot bind argument to parameter 'InputObject' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.5.136\Internal\Invoke-JiraMethod.ps1:97 char:54
+ $result = ConvertFrom-Json2 -InputObject $responseBody
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertFrom-Json2], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,ConvertFrom-Json2
XML response (via Wireshark):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<status>
<status-code>401</status-code>
<message>This resource requires WebSudo.</message>
</status>
It would be great to be able to import issues from other systems to JIRA using PSJira. For example, CSV is probably one of the most commonly used files to do this. Would save time to be able to import files from command line.
Documentation:
https://confluence.atlassian.com/adminjiraserver071/importing-data-from-csv-802592885.html
Would be nice to be able to manage Watchers on an issue
With the current cmdlet set, it's not possible to create an issue that is a sub-task because the issue requires a Parent
to be specified, however the New-JiraIssue
cmdlet does not accept a parent field because it is not returned in the set of available fields by the Get-JiraField
cmdlet.
The missing parent
field issue appears to be reflected by this JIRA bug. Presumably this is an implied global field.
But as shown in this API tutorial example for creating sub-task issues, the parent is required.
Currently, Get-JiraUser always uses the /search method. I'd like it if there was an option to just grab a user by username, without searching.
Assume two users:1
John Smith
, username john
John Smith
, username smith
Get-JiraUser -UserName 'john'
Name DisplayName Active
---- ----------- ------
john John Smith True
smith John Smith True
Name DisplayName Active
---- ----------- ------
john John Smith True
I actually ran into this when I was trying to create my first issue, as in #28. Because New-JiraIssue
is verifying all inputs, it was using Get-JiraUser
to transform my simple, unassuming username string into a gorgeous, intricate, yet worthless array of two objects.
$userGetUrl already acknowledges the desired URI, but isn't called later in the current Get-JiraUser
code.
There's two ways to fix this, if desired. The optimal method, IMHO, is also a breaking change. (Get-JiraUser
grabs a username, and a new Find-JiraUser
performs a search if desired.)
That leaves the solution for real people in real life, which is probably a switch parameter like -NoSearch
or -Exact
or something that hits the "get" URI instead of the "find" URI.
I can submit a PR if you agree.
This module is the best, and I'm sorry you're not working with JIRA day-to-day anymore. Thanks, I love you, stay gold, etc.
1 - I know this is a really dumb issue, exacerbated by a lame fictional naming convention. And it may be making me question my own sanity a little in sitting here filing it. But here I am anyway, and here you are, reading this while wondering the same thing, so I might as well try to make it a little enjoyable. ↩
The ability to manage project roles would be handy for automation. We can already accomplish this by managing group memberships, but more options never hurt anyone.
Get-JiraGroupMember only returns the first 50 Users of a group... any more members will be ignored...
can you implement getting all users of a group?
Hi,
First of all nice work, this module saves me time.
But i have a question about Set-JiraIssue
I want to update a custom field but this custom field is a dropdown field how do i update this?
field is called "Environment Sx" (customfield_11154)
Possible values: Production, Test, Acceptance, Development
I tried the following commands but that did not work:
Current value of that field is Development or id 14753 and i want to update it to production or id 14750
Set-JiraIssue -Issue $JiraIssue -Fields @{'Environment Sx' = 'Production';}
Set-JiraIssue -Issue $JiraIssue -Fields @{'Customfield_11154' = 'Production';}
Set-JiraIssue -Issue $JiraIssue -Fields @{'Customfield_11154' = '14750';}
14750 = Value Production
But the result of all the commands are the same: WARNING: JIRA returned HTTP error 400 - BadRequest
It is possible to get the current value:
$JiraIssue.customfield_11154
returns:
Is custom field with dropdown not supported or is my code wrong?
There are some pretty significant drawbacks to the current config.xml structure:
$env:ProgramFiles\WindowsPowerShell\Modules\PSJira
in order to modify the file (typically means admin rights)The only major pro to this system is that you can set it up once and forget about it if you never need to change JIRA instances. Admin rights are required once, to set up the file, but aren't required each time you use the module.
I'm interested in re-thinking this structure to try to reduce those negative points. In no particular order, here are some ideas:
Multiple config files
Saving server URL in JiraSession object and allowing user to specify a session via parameter
# Example 1
$session = New-JiraSession -Credential (Get-Credential) -ServerUrl 'https://jira.example.com'
Get-JiraIssue TEST-01 -Session $session
# Example 2
$session = New-JiraSession -Credential (Get-Credential) -ServerUrl 'https://jira.example.com'
$session2 = New-JiraSession -Credential (Get-Credential) -ServerUrl 'https://jira2.example.com:8080'
Set-JiraSession $session
Get-JiraIssue TEST-01 # Uses $session
Set-JiraSession $session2
Get-JiraIssue FOO-99 # Uses $session2
Support for multiple server URLs in config.xml
# Example 3
Set-JiraConfigServer -Instance 'prod' -Url 'https://jira.example.com'
New-JiraSession -Credential $cred -Instance 'prod'
Get-JiraIssue TEST-01 # will use the stored Session for the prod instance
...or...
# Example 4
Set-JiraConfigServer -Instance 'prod' -Url 'https://jira.example.com'
New-JiraSession -Credential $cred -Instance 'prod'
Get-JiraIssue TEST-01 -Instance 'prod'
# If prod doesn't have a saved session, use anonymous access (with a Write-Warning message)
Configuration module for PowerShell
Thoughts and opinions welcome. Anyone care to chime in on this?
Hello,
Could you please tell me how to setup security level field on comments or issue ?
I think i should use :
#@{'Security Level'= '10401'}
But how do you find this id of the security level, i can't find out on Jira documentation.
I need to post comment and issue visible to "everyone"
Actually, my comments are limited to "Developpers"
Thanks for your help,
zoph
Since label support was added we can no longer create new Jira issues. New-JiraIssue.ps1 shows:
DEBUG: [Resolve-JiraError] Writing Error output for error [labels]
Resolve-JiraError : Jira encountered an error: [labels] - Field 'labels' cannot be set. It is not on the appropriate screen, or unknown.
Our workaround is to comment out creation of the $props.labels property in New-JiraIssues.ps1. Can a modification be made to exclude the creation of $props.labels if the $Labels parameter is blank or not passed? This will provide a more permanent solution. Thanks.
Add support for adding, modifying, and removing labels to issues.
Really great to see the recent changes added to PSJira.
I've had a few instances recently where I needed to perform additional field changes along with an issue transition. Using a separate Set-JiraIssue wasn't an option due to our JIRA configuration (permissions). Changing fields along with a transition is supported in the JIRA API so I thought I'd have a crack at adding this functionality. Essentially I have copied and adapted the field parameter functionality from Set-JiraIssue.
I have also given my best shot at updating the pester tests for this new parameter. As above I have copied and adapted the fields parameter test from Set-JiraIssue.Tests. The new test passes, but I'm still getting my head around pester testing in general so would be interested to know if you think this new test is adequate.
Let me know if you're happy with these changes and I'll submit a pull do the Dev branch.
Invoke-JiraIssueTransition.txt
Invoke-JiraIssueTransition.Tests.txt
Thanks
Padgers
I have a project where the Priority field is hidden. I can't use New-JiraIssue to create an issue in this project, because the -Priority parameter is mandatory.
Confirmed with the following steps:
$json
$hashtable.fields.Remove('priority')
$json = ConvertTo-Json -InputObject $hashtable -Depth 3
Can you think of any reason this parameter needs to remain mandatory?
Invoke-Pester getting errors on ConvertTo-JiraProject
[-] Uses ConvertTo-JiraProject to return the project as an object 61ms Expected string length 14 but was 15. Strings differ at index 0. Expected: {PSJira.Project} But was: {System.Object[]}
However if I pipe a returning object to get-member I'm getting TypeName: PSJira.Project
Hey there
Really appreciate this PS Module. Saving me hours of work coding this myself.
This might be more of a question than a feature request:
Is there a reason you return self created custom PSObjects for Get-JIRAIssueCreateMetaData with less data than returned by the REST method?
Noticed this when I was looking for the allowed values, which are lost as they are not handed over.
For now I built in a switch $returnJSON to the cmdlet which returns the $fields object instead of the custom object. This did the trick for me but wanted to know why it was designed like that. And maybe as an improvement for the future.
Cheers
When using the -Filter parameter in Get-JiraIssue, if the -MaxResults parameter is not also provided, the function will only return one issue result.
Expected behavior: If -MaxResults is not provided, Get-JiraIssue should return all results when using the -Filter parameter, just as it does when using the -Query parameter.
This function needs to return field IDs to solve some errors in New-JiraIssue.
Hi,
any chance to add the StartAt when requesting the search endpoint ? it would allow to get all issue.
Even better, maybe all to retrieve all items by looping ?
Hey,
When attempting to create an issue with the component field set I'm receiving the following error:
_WARNING: JIRA returned HTTP error 400 - BadRequest
Resolve-JiraError : Jira encountered an error: [components] - data was not an array
At C:\windows\system32\windowspowershell\v1.0\Modules\PSJira\Functions\Internal\Invoke-JiraMethod.ps1:99 char:13
Resolve-JiraError $result -WriteError
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The command i'm using is as follows:
New-JiraIssue -Project TestProject -IssueType Story -Summary "Test Issue" -Description "Test Desc" -Pr
iority 1 -Reporter "me" -Fields @{'components'='RTST'}
I've also tried replacing 'RTST' with a powershell array, but no joy :(
Also - thanks for this work, it's going to be extremely helpful once I get it working!
Cheers,
Tom
Hi,
I use Jira for work and am trying to utilise your functions to pull some data.
When I try and create the Jira session I got unhandled exceptions (just after line 89 in New-JiraSession) because the $webresponse was empty.
The Jira server URL has a port specified - not sure if that might cause any issues?
are there any settings on the Jira side which might prevent me from using your functions?
Debug log:
DEBUG: [New-JiraSession] Reading Jira server from config file
DEBUG: [New-JiraSession] Created JSON syntax in variable $json.
DEBUG: [New-JiraSession] Preparing for blastoff!
WARNING: The underlying connection was closed: An unexpected error occurred on a send.
DEBUG: [New-JiraSession] Encountered an exception from the Jira server: The underlying connection was closed: An unexpected error occurred on a send.
WARNING: JIRA returned HTTP error value: -
Thanks,
Steve
I guess the issue is with the api change
Extend support for issues by adding methods for issue links:
New-JiraIssueLink
-Type
Jira.IssueLinkType?-InwardIssue
Jira.Issue-OutwardIssue
Jira.Issue-Comment
Get-JiraIssueLink
-Issue
Jira.Issue
-Link
int/Jira.IssueLink
Remove-JiraIssueLink
-Link
int/Jira.IssueLink
Get-JiraIssueLinkType
-Link
int/Jira.IssueLink: GET /rest/api/2/issueLinkType/{issueLinkTypeId}New-JiraIssueLinkType
POST /rest/api/2/issueLinkType
-Name
string-Inward
string-Outward
stringRemove-JiraIssueLinkType
DELETE /rest/api/2/issueLinkType/{issueLinkTypeId}
-LinkType
int/Jira.IssueLinkTypeSet-JiraIssueLinkType
or Update-JiraIssueLinkType
PUT /rest/api/2/issueLinkType/{issueLinkTypeId}
-LinkType
Jira.IssueLinkType mandatory-Name
string optional-Inward
string optional-Outward
string optionalParameterSetName
This issue is NOT about Remote Issue Links - although that would be a cool thing to have access to through PowerShell, that looks like it will be more time intensive to implement, so I'm not ready to tackle that just yet.
Remote Issue Links were implemented with #80
When trying to use Set-JiraIssue the Jira issue updates as expected but I get the following error:
$objHash = @{
customfield_11400 = @{
id = "11317"
}
}
Set-JiraIssue -Issue OPS-4526 -Credential $jiraCred -Fields $objHash
ERROR:
ConvertFrom-Json2 : Cannot bind argument to parameter 'InputObject' because it is an empty string.
At C:\Users\chalford\Documents\WindowsPowerShell\Modules\PSJira\1.2.5.112\Internal\Invoke-JiraMethod.ps1:93 char:54
$result = ConvertFrom-Json2 -InputObject $webResponse.Content
I traced the problem to Invoke-JiraMethod not being able to handle '204 No content' results from Invoke-WebRequest which according to the REST API documentation is the standard success response. Error trapping should test for $webResponse.Content before calling ConvertFrom-Json2 or should have a test for ($webResponse.StatusCode -eq 204)
Hoping the above proves useful.
Regards.
Resolve-JiraError : Jira encountered an error: [customfield_10301] - Can not instantiate value of type [simple type,class com.atlassian.jira.issue.fields.rest.json.beans.GroupJsonBean] from JSON String; no single-String constructor/factory method
Field is populated from a Group Picker control, and is a single selection field.
Managing JIRA users has been a popular request since PSJira's release. Add the ability to manage users and groups in JIRA to the module.
Jira automatically creates RemoteLinks when a bound system links to the Issue (eg: Jira macro from confluence).
These can be retrieved as documented in Atlassians REST docs
When is the next release out to PSGallery to synchronize the JSON pull I made a little while back?
PS - Have you considered asking for an OSS license? https://www.atlassian.com/software/views/open-source-license-request
1.2.5.135 PSJira
JIRA v7.1.7
Hello,
Everything works fine and I can get/create issues, but Add-JiraIssueComment doesn't create comments.
I see that Jira returned 401, but get-jirasession shows me active session.
PS C:> Add-JiraIssueComment -Issue THD-3 -Comment "test"
WARNING: JIRA returned HTTP error 401 - Unauthorized
Exception calling "DeserializeObject" with "1" argument(s): "Invalid JSON primitive: ."
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.5.135\Internal\ConvertFrom-Json2.ps1:97 char:6
$jsonTree = $jsonserial.DeserializeObject($InputObject)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [], MethodInvocationException
- FullyQualifiedErrorId : ArgumentException
ConvertTo-JiraComment : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.5.135\Public\Add-JiraIssueComment.ps1:113 char:54
$result = ConvertTo-JiraComment -InputObject $rawResult
~~~~~~~~~~
- CategoryInfo : InvalidData: (:) [ConvertTo-JiraComment], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,ConvertTo-JiraComment
PS C:> Get-JiraIssue THD-03 | Add-JiraIssueComment "Test comment from PowerShell (again)"
WARNING: JIRA returned HTTP error 401 - Unauthorized
The variable cannot be validated because the value is not a valid value for the Body variable.
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.5.135\Internal\Invoke-JiraMethod.ps1:94 char:13
$body = $readStream.ReadToEnd()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : MetadataError: (:) [], ValidationMetadataException
- FullyQualifiedErrorId : ValidateSetFailure
ConvertFrom-Json2 : Cannot bind argument to parameter 'InputObject' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.5.135\Internal\Invoke-JiraMethod.ps1:97 char:54
$result = ConvertFrom-Json2 -InputObject $body
~~~~~
- CategoryInfo : InvalidData: (:) [ConvertFrom-Json2], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,ConvertFrom-Json2
HI, i tryed to create a ticket with
new-JiraIssue -Project TCJ -IssueType Bug -Fields @{'Security Level'= '10401'} -Summary 'Test issue from PowerShell' -Description 'this is the test descr. ' -Priority '1'
Return failure message:
Unable to identify issue reporter. You must provide either the -Reporter parameter or the -Credential parameter, or
the currently logged-on user must be a valid Jira user.
At C:\Program Files\WindowsPowerShell\Modules\psjira\Functions\New-JiraIssue.ps1:109 char:17
throw "Unable to identify issue reporter. You must provide eithe ...
- CategoryInfo : OperationStopped: (Unable to ident...alid Jira user.:String) [], RuntimeException
- FullyQualifiedErrorId : Unable to identify issue reporter. You must provide either the -Reporter parameter or th
e -Credential parameter, or the currently logged-on user must be a valid Jira user.
i tryed different users - but I'm not able to create a ticket - to add a comment works fine
When running a Get-JiraIssue -Query 'project = ""' never returns a valid response, and appears to be hung. The query had no response after 5 minutes of waiting, however, when performing the same JQL in Jira interface, the response is near immediate and populated.
Our JIRA has a lot of custom fields (800 for each ticket...) so it takes 10 seconds to retrieve one ticket.
I tracked down the issue, and the issue is in the function converting the result from the request to a jiraissue object. Please find enclosed a patch that accelerated greatly the speed of the function
patch.diff.convertjiraissue.txt
you may be able to reuse similar code at other places.
Hello! Thanks for the great work you've done here!
When running Invoke-Pester for the module, the result is: Passed: 62 Failed: 44 Skipped: 0 Pending: 0 Inconclusive: 0
Error output:
[-] Error occurred in test script 'C:\Projects\PSJira\PSJira\Internal\ConvertTo-JiraComment.Tests.ps1' 45ms
RuntimeException: Module 'PSJira' is not a Script module. Detected modules of the following types: ''
at Get-ScriptModule, C:\Program Files\WindowsPowerShell\Modules\Pester\3.4.0\Functions\InModuleScope.ps1: line 128
[-] Error occurred in test script 'C:\Projects\PSJira\PSJira\Internal\ConvertTo-JiraCreateMetaField.Tests.ps1' 45ms
RuntimeException: Module 'PSJira' is not a Script module. Detected modules of the following types: ''
at Get-ScriptModule, C:\Program Files\WindowsPowerShell\Modules\Pester\3.4.0\Functions\InModuleScope.ps1: line 128
The issue is that the module has not been loaded. If I run Import-Module .\PSJira\PSJira.psm1
then run the Pester tests, it succeeds.
Suggesting tests to include Import-Module
. A workaround is to manually ensure the module is loaded, but if you forget to reload the module, you'll be testing an out-of-date module.
Best,
CD
Recommendation:
Please add check for double slash usage on Set-JiraConfigServer :)
After playing arround with errors for a fair bit I discovered a easy to make human error. When using a slash at the end of your Set-JiraConfigServer URL, all scripts fail....of course..
Fails: Set-JiraConfigServer "https://test.jira.com/"
Works: Set-JiraConfigServer "https://test.jira.com"
Discovered this when using verbose logging, didn't see it the first couple of times:
Get-JiraIssue -Key Issue -Verbose
Returned:
VERBOSE: No Jira sessions have been saved.
VERBOSE: GET http://test.jira.com**//**rest/api/latest/issue/Issue?expand=transitions with 0-byte payload
WARNING: JIRA returned HTTP error 404 - NotFound
Set-JiraConfigServer "https://test.jira.com/"
Get-JiraIssue -Key Issue -Verbose
VERBOSE: No Jira sessions have been saved.
VERBOSE: GET http://test.jira.com**//**rest/api/latest/issue/Issue?expand=transitions with 0-byte payload
WARNING: JIRA returned HTTP error 404 - NotFound
The variable cannot be validated because the value is not a valid value for the Body variable.
At C:\Userpath\WindowsPowerShell\Modules\PSJira\Internal\Invoke-JiraMethod.ps1:88 char:13
+ $body = $readStream.ReadToEnd()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (:) [], ValidationMetadataException
+ FullyQualifiedErrorId : ValidateSetFailure
ConvertFrom-Json2 : Cannot bind argument to parameter 'InputObject' because it is an empty string.
At C:\Userpath\WindowsPowerShell\Modules\PSJira\Internal\Invoke-JiraMethod.ps1:91 char:54
+ $result = ConvertFrom-Json2 -InputObject $body
+ ~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertFrom-Json2], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,ConvertFrom-Json2
Is it possible to request this feature to specify a custom field like:
Set-JiraIssue -Key TEST-001 -Field "customfield_12345" -Value 2015-10-07T10:24:00.000-0700
or in a more RESTful manner have:
Update-JiraIssue TEST-001
That way the changes done to TEST-001 get sync'd back.
Awesome job on this!
If we take an issue and pipe it to Set-JiraIssue using the Fields parameter certain fields will throw errors as they do not support the 'set' operation. A good example is Comment.
Take:
$fields = @{};
$fields.comment = "The insightful awesome comment I want to add!"
Get-JiraIssue -Key "Test01" | Set-JiraIssue -Fields $fields
The Result is of the code above yields:
Resolve-JiraError : Jira encountered an error: [Field with id' comment' and name 'Comment' does not
support operation 'set' Supported operation(s) are: 'add,edit,remove']
Currently in Set-JiraIssue:
$issueProps.update.$id += @{
'set' = $value;
}
The change I would propose, is to add a $FieldOperation. ParameterSet could be nice however that may pigeon hole other fields that don't conform. So it might be better off as an open string field. Thoughts?
$operation = "$($FieldOperation)"
$issueProps.update.$id += @{
$operation = $value;
}
All in all this module has been awesome, thank you for making it you are greatly appreciated!
Great project! I can see myself getting tons of use from this module.
I found what I believed to be a problem with the encoding of data returned from Get-JiraIssue (and presumably other Get operations that rely on /PSJira/Functions/Internal/Invoke-JiraMethod.ps1).
When returning information from issues containing non-standard characters (such as "é"), the get-jiraissue would return "??" indicating an encoding issue.
I had a crack at finding and fixing the problem. Testing with the Invoke-JiraMethod function I could see characters present and correct in objects returned from the Invoke-WebRequest cmdlet. When processing the object through ConvertFrom-Json the characters are lost. ConvertFrom-Json seems to break encoding of the input object. However, if I pass along just the Content property of the returned web request object, the processing by ConvertFrom-Json returns a result with correct characters.
I have forked the code for Invoke-JiraMethod with the proposed change. I'm not 100% sure if this change would have some negative impact, but it's worked well with the tests I have performed with the get-jiraissue function.
By the way, I'm new to Git Hub - so please don't hesitate to correct me/advise me if I'm going about this all wrong!
Neil
It is not possible to create an Issue without providing a reporter.
This can lead to the following error (as it does for me):
WARNING: JIRA returned HTTP error 400 - BadRequest
Resolve-JiraError : Jira encountered an error: [reporter] - Field 'reporter' cannot be set. It is
not on the appropriate screen, or unknown.
When no value is provided to the parameter Reporter
, as it is not mandatory in the param()
section of New-JiraIssue
, the function sets a "fallback" value:
if ($Reporter)
{
} else {
$reporterStr = $env:USERNAME
}
$ReporterParam = New-Object -TypeName PSObject -Property @{"name"=$reporterObj.Name}
$props = @{
"reporter"=$ReporterParam
}
{
$ProjectParam = New-Object -TypeName PSObject -Property @{"id"=$ProjectObj.Id}
$IssueTypeParam = New-Object -TypeName PSObject -Property @{"id"=[String] $IssueTypeObj.Id}
$props = @{
"project"=$ProjectParam;
"summary"=$Summary;
"issuetype"=$IssueTypeParam;
}
if ($Priority) {
$props.priority = New-Object -TypeName PSObject -Property @{"id"=[String] $Priority}
}
if ($Description) {
$props.description = $Description
}
if ($Reporter) {
$props.reporter = New-Object -TypeName PSObject -Property @{"name"=$reporterObj.Name}
}
This module needs more documentation!
Getting Started should show some more concrete examples, including creating and actively working with an issue. Possibly even with screenshots.
Currently, you can change an existing Fix Version field like this:
Set-JiraIssue TEST-01 -Fields @{
'fixVersions'=@(
@{
name='MyFixedVersion'
}
)
}
Or for a more variable method:
$VersionHash = @{"name" = "MyFixedVersion"}
$VersionArray = @($VersionHash)
$field = @{"fixVersions" = $VersionArray}
Set-JiraIssue -Fields $field
It would be nice to add a param to Set-JiraIssue to encapsulate this a bit.
Also, potentially providing support for adding fix versions when they don't already exist.
You cannot call a method on a null-valued expression.
$readStream = New-Object -TypeName System.IO.StreamReader -ArgumentL ...
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
Pointing to New-JiraSession.ps1:92 char:13
$readStream = New-Object -TypeName System.IO.StreamReader -ArgumentList ($webResponse.GetResponseStream())
Calling Invoke-JiraIssueTransition updates the Jira issue status but also returns the following error:
ERROR:
ConvertFrom-Json2 : Cannot bind argument to parameter 'InputObject' because it is an empty string.
At C:\Users\chalford\Documents\WindowsPowerShell\Modules\PSJira\1.2.5.112\Internal\Invoke-JiraMethod.ps1:93 char:54
$result = ConvertFrom-Json2 -InputObject $webResponse.Content
Me again :)
You might want to add support for all the fun characters such as ä ü ö (wont even start with the nordic ones :))
Checkout: http://stackoverflow.com/questions/15290185/invoke-webrequest-issue-with-special-characters-in-json
You could pretty easily do that by encoding the body of the Webrequest in the Invoke-JiraMethod with something like:
$EncBody = [System.Text.Encoding]::UTF8.GetBytes($Body)
And then handing over the UTF8 body. Works very well for me.
PS: Sorry for not Push/Pulling such requests. Working on it with my IT security that our proxy allows it :-S
I am having trouble with this module because of it's performance.
Let me explain: when making changes to an issue, this module does a lot of queries to validate data (field y, user, etc)
However, when walking through a list of ~300 issues, the time the script takes to process all API calls takes a very long time, whereas other tools (Python library for jira's API) does the same in few minutes.
I have a script in which I do a couple of actions ( create issue with approx 20 fields, edit issue because field was not in creation screen, create links to other issues). There script takes about 2 minutes to finish a ticket before moving to the in the loop.
As a jira administrator, I would like to be able to return an object representing a project within jira, modify the object properties with the corresponding classes or child objects, and reconfigure a project by saving that model back to the jira server.
For example:
$project = Get-JiraProjectObjectModel -ProjectKey "Foo"
$project.ProjectRoleModel.Roles[3].Members.Add(Get-JiraUser "someuser")
Validate-JiraProjectObjectModel -Object $project
Update-JiraProjectObjectModel -Object $project
New-JiraProjectObjectModel -ReferenceObject $project -ProjectKey "NewFoo"
Jira v6.4.10#64025
Powershell Version is 5.0.10586.122
I've installed the PSJira module and Set-JiraConfigServer, after that you can see details below ...
PS C:> New-JiraSession -Credential (Get-Credential)
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
WARNING: JIRA returned HTTP error -
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.4.85\Functions\New-JiraSession.ps1:92 char:13
$readStream = New-Object -TypeName System.IO.StreamReader ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.