GithubHelp home page GithubHelp logo

atlassianps / jiraps Goto Github PK

View Code? Open in Web Editor NEW
323.0 41.0 131.0 2.63 MB

PowerShell module to interact with Atlassian JIRA

Home Page: https://AtlassianPS.org/module/JiraPS

License: MIT License

PowerShell 99.83% Dockerfile 0.17%
powershell powershell-gallery rest api atlassianps jira atlassian windows-powershell

jiraps's Introduction

AtlassianPS

jiraps's People

Contributors

adminturneddevops avatar alexsuslin avatar asherber avatar axxelg avatar azure-pipelines[bot] avatar beaudryj avatar ctolan avatar dejulia489 avatar dependabot[bot] avatar ebekker avatar hmmwhatsthisdo avatar jkknorr avatar johnheusinger avatar jschlackman avatar kb-cs avatar kittholland avatar liamleane avatar lipkau avatar lmf-mx avatar mirrorgleam avatar myounger avatar padgers avatar pdx-nojp avatar replicajunction avatar rufus125 avatar sgtwilko avatar spascoe avatar thepsadmin avatar tomasdeceuninck avatar tuxgoose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jiraps's Issues

Trying to create New-JiraIssue with customfield

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,

New-JiraUser fails with 401 Unauthorized with WebSudo enabled

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>

Unable to create sub-task issues because parent field is not accepted

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.

Get-JiraUser is too helpful

Overview

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.

Steps to Reproduce

Assume two users:1

  1. John Smith, username john
  2. John Smith, username smith

Get-JiraUser -UserName 'john'

Results

Actual

Name    DisplayName   Active
----    -----------   ------
john    John Smith    True
smith   John Smith    True

Expected (well...hoped for)

Name    DisplayName   Active
----    -----------   ------
john    John Smith    True

Background

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.

Suggestions

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.

Brown-nosing

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.

Add support for project roles

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.

Project roles

Help With Custom Fields

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
result

It is possible to get the current value:
$JiraIssue.customfield_11154
returns:
return

Is custom field with dropdown not supported or is my code wrong?

Sessions and server URLs

There are some pretty significant drawbacks to the current config.xml structure:

  • If PSJira is installed system-wide, the user's PowerShell session must have rights to write to $env:ProgramFiles\WindowsPowerShell\Modules\PSJira in order to modify the file (typically means admin rights)
  • No easy way to alternate between more that one JIRA server without modifying the config file each time
  • XML is awkward (my opinion)

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

    • User might need to specify a config file on a regular basis (add the -ConfigFile param to more functions).
  • Saving server URL in JiraSession object and allowing user to specify a session via parameter

    • Something like this:
    # Example 1
    $session = New-JiraSession -Credential (Get-Credential) -ServerUrl 'https://jira.example.com'
    Get-JiraIssue TEST-01 -Session $session
    • User would need to enter the URL when creating a session - this would affect normal use of the module. That's my biggest hesitation with this method, since it would be a breaking change.
    • Above could be mitigated by adding New-JiraSession to the user's PowerShell profile, but that would require user saving credentials to disk as well (for the -Credential param)
    • Users who use the -Credential param instead of creating a session would need an alternate method of providing the server URL, so anything with the -Credential param might need a -Url param as well
    • Could still save the most recently used session in module PrivateData...maybe Get- and Set-JiraSession?
    # 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

    • Provide a name or ID for each URL, then add a -Instance param to functions
    # 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)
    • Doesn't really make alternating between sessions any easier, unless I added Get- and Set-JiraSession to update the stored session with one from a variable
  • Configuration module for PowerShell

    • Introduces a module dependency
    • Solves the XML and permissions issues, but doesn't address switching between environments - I'd need to combine this with one of the above examples

Thoughts and opinions welcome. Anyone care to chime in on this?

Security Level for comments or Issue

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

Label support in New-JiraIssue prevents creation of issue

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 Fields parameter on Invoke-JiraIssueTransition

Hi @replicaJunction

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

Create Issue Without Priority

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:

  • Set a breakpoint on line 185 of New-JiraIssue
  • Run New-JiraIssue with desired parameters
  • Prompted to enter a value for mandatory parameter Priority
  • Enter breakpoint
  • $json
    • Includes the priority
  • $hashtable.fields.Remove('priority')
  • $json = ConvertTo-Json -InputObject $hashtable -Depth 3
  • Exit breakpoint
  • Issue is created successfully

Can you think of any reason this parameter needs to remain mandatory?

ConvertTo-JiraProject Pester Error

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

Feature Request/Question: Return JSON switch for Get-JIRAIssueCreateMetaData

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

Get-JiraIssue only returns one issue in some cases when -Filter is specified

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.

get-JiraIssue does not use StartAt

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 ?

Jira encountered an error: [components] - data was not an array

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
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Resolve-JiraError_

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

Error in New-JiraSession: "The underlying connection was closed"

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

Add support for issue links

Extend support for issues by adding methods for issue links:

api/2/issueLink

api/2/issueLinkType

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

Invoke-JiraMethod error when Invoke-WebRequest returns '204 No content'

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.

When calling New-JiraIssue with custom required field, error is returned

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.

Implement user management

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.

Add-JiraIssueComment Cannot bind argument to parameter 'InputObject' because it is null

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

cannot create Issue - You must provide either the -Reporter parameter or the -Credential

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

GEt-jiraissue is slow

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.

Pester error: RuntimeException: Module 'PSJira' is not a Script module.

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

JiraConfigServer double slash results in 404 errors

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

Set-JiraIssue cannot handle custom fields

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!

Add parameter for non-set operations in Set-JiraIssue

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!

Encoding return problem with Invoke-JiraMethod

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

-Repoter is mandatory in New-JiraIssue

Problem

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.

Reason

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
        }

Possible Solution

    {
        $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}
        }

Documentation

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.

Add support for FixVersions field in Set-JiraIssue

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.

WARNING: JIRA returned HTTP error

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())

Invoke-JiraIssueTransition error (same as issue #42)

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

UTF- 8 Encoding of Invoke-Webrequest Body

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

Performance

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.

Get, Create and Update project objects

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"

You cannot call a method on a null-valued expression.

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 ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.