Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{ps1,psm1,psd1,psc1,ps1xml,clixml}]
[*.{md,ps1,psm1,psd1,psc1,ps1xml,clixml}]
end_of_line = crlf


Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.md text
*.gitattributes text

# Set merge behavior for the changelog
CHANGELOG.md merge=union

# Declare files that will always have CRLF line endings on checkout.
*.md text eol=crlf
*.ps1 text eol=crlf
*.psm1 text eol=crlf
*.psd1 text eol=crlf
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
shell: pwsh
run: |
./Tools/setup.ps1
Invoke-Build -Task ShowInfo
Invoke-Build -Task ShowDebugInfo
- name: Build
shell: pwsh
run: |
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
shell: powershell
run: |
./Tools/setup.ps1
Invoke-Build -Task ShowInfo
Invoke-Build -Task ShowDebugInfo
- name: Test
shell: powershell
run: |
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
shell: pwsh
run: |
./Tools/setup.ps1
Invoke-Build -Task ShowInfo
Invoke-Build -Task ShowDebugInfo
- name: Test
shell: pwsh
run: |
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
shell: pwsh
run: |
./Tools/setup.ps1
Invoke-Build -Task ShowInfo
Invoke-Build -Task ShowDebugInfo
- name: Test
shell: pwsh
run: |
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
shell: pwsh
run: |
./Tools/setup.ps1
Invoke-Build -Task ShowInfo
Invoke-Build -Task ShowDebugInfo
- name: Test
shell: pwsh
run: |
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
shell: pwsh
run: |
./Tools/setup.ps1
Invoke-Build -Task ShowInfo
Invoke-Build -Task ShowDebugInfo
- name: Test
shell: pwsh
run: |
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

### Changed

- Changed all commands to only use Jira's api version 2. (#409, [@lipkau])
- Changed all commands to only use Jira's api version 2. (#409, [@lipkau])
This is a temporary fix and should be reverted to version `latest` as soon as
a proper handling of how users work between cloud and on-premise is
implemented
Expand Down
55 changes: 40 additions & 15 deletions JiraPS.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@ param(
)

Import-Module "$PSScriptRoot/Tools/BuildTools.psm1" -Force
Import-Module (Get-Dependency) -Force -ErrorAction Stop

Remove-Item -Path env:\BH* -ErrorAction SilentlyContinue
Set-BuildEnvironment -BuildOutput '$ProjectPath/Release' -ErrorAction SilentlyContinue
$OS, $OSVersion = Get-HostInformation
# Add-ToModulePath -Path $env:BHBuildOutput

#region HarmonizeVariables
switch ($true) {
{ $IsWindows } {
$OS = "Windows"
if (-not ($IsCoreCLR)) {
$OSVersion = $PSVersionTable.BuildVersion.ToString()
}
}
{ $IsLinux } {
$OS = "Linux"
}
{ $IsMacOs } {
$OS = "OSX"
}
{ $IsCoreCLR } {
$OSVersion = $PSVersionTable.OS
}
}
#endregion HarmonizeVariables

if ($VersionToPublish) {
$VersionToPublish = $VersionToPublish.TrimStart('v') -as [Version]
Expand Down Expand Up @@ -111,7 +127,7 @@ Task CompileModule {
}

# Synopsis: Use PlatyPS to generate External-Help
task GenerateExternalHelp {
Task GenerateExternalHelp {
Import-Module platyPS -Force
foreach ($locale in (Get-ChildItem "$env:BHProjectPath/docs" -Attribute Directory)) {
New-ExternalHelp -Path "$($locale.FullName)" -OutputPath "$env:BHModulePath/$($locale.Basename)" -Force
Expand Down Expand Up @@ -142,17 +158,26 @@ Task SetVersion {
}

Task Test {
$pesterConfig = [PesterConfiguration]::Default
$pesterConfig.Output.Verbosity = $PesterVerbosity
$pesterConfig.Run.path = @("$env:BHBuildOutput/Tests")
$pesterConfig.Run.PassThru = $true
$PesterConfig.TestResult.Enabled = $true
$pesterConfig.TestResult.OutputFormat = 'NUnitXml'
$pesterConfig.TestResult.OutputPath = "TestResults.xml"

if ((Invoke-Pester -Configuration $pesterConfig).FailedCount -gt 0) {
throw "Tests failed"
$pesterConfig = New-PesterConfiguration -Hashtable @{
Run = @{
PassThru = $true
Path = "$env:BHBuildOutput/Tests"
}
TestResult = @{
Enabled = $true
OutputFormat = 'NUnitXml'
OutputPath = "Test-$OS-$($PSVersionTable.PSVersion.ToString()).xml"
}
Output = @{
Verbosity = $PesterVerbosity
}
<# CodeCoverage = @{
Path = $codeCoverageFiles
} #>
}

$testResults = Invoke-Pester -Configuration $pesterConfig
Assert-True ($testResults.FailedCount -eq 0) "$($testResults.FailedCount) Pester test(s) failed."
}

Task Publish SetVersion, SignCode, Package, {
Expand Down
4 changes: 2 additions & 2 deletions JiraPS/Private/ConvertFrom-URLEncoded.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function ConvertFrom-URLEncoded {
)

process {
foreach ($input in $InputString) {
foreach ($string in $InputString) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Decoding string from URL"
[System.Web.HttpUtility]::UrlDecode($input)
[System.Web.HttpUtility]::UrlDecode($string)
}
}
}
4 changes: 2 additions & 2 deletions JiraPS/Private/ConvertTo-URLEncoded.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function ConvertTo-URLEncoded {
)

process {
foreach ($input in $InputString) {
foreach ($string in $InputString) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Encoding string to URL"
[System.Web.HttpUtility]::UrlEncode($input)
[System.Web.HttpUtility]::UrlEncode($string)
}
}
}
12 changes: 6 additions & 6 deletions JiraPS/Private/Resolve-ErrorWebResponse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Resolve-ErrorWebResponse {
Exception = $exception
ErrorId = $errorId
Category = $errorCategory
Message = "An unknown error ocurred."
Message = "An unknown error occurred."
TargetObject = $targetObject
Cmdlet = $Cmdlet
}
Expand All @@ -89,11 +89,11 @@ function Resolve-ErrorWebResponse {
else {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Response had no Body. Using `$StatusCode for generic error"
$writeErrorSplat = @{
Exception = $exception
ErrorId = $errorId
Category = $errorCategory
Message = "Server responsed with $StatusCode"
Cmdlet = $Cmdlet
Exception = $exception
ErrorId = $errorId
Category = $errorCategory
Message = "Server responded with $StatusCode"
Cmdlet = $Cmdlet
}
WriteError @writeErrorSplat
}
Expand Down
14 changes: 7 additions & 7 deletions JiraPS/Private/Test-ServerResponse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function Test-ServerResponse {
[CmdletBinding()]
<#
.SYNOPSIS
Evauluate the response of the API call
Evaluate the response of the API call
.LINK
https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/bc/security/login/LoginReason.html
#>
Expand All @@ -28,7 +28,7 @@ function Test-ServerResponse {
$loginReason = $InputObject.Headers[$loginReasonKey] -split ","

switch ($true) {
{$loginReason -contains "AUTHENTICATED_FAILED"} {
{ $loginReason -contains "AUTHENTICATED_FAILED" } {
$errorParameter = @{
ExceptionType = "System.Net.Http.HttpRequestException"
Message = "The user could not be authenticated."
Expand All @@ -38,17 +38,17 @@ function Test-ServerResponse {
}
ThrowError @errorParameter
}
{$loginReason -contains "AUTHENTICATION_DENIED"} {
{ $loginReason -contains "AUTHENTICATION_DENIED" } {
$errorParameter = @{
ExceptionType = "System.Net.Http.HttpRequestException"
Message = "For security reasons Jira requires you to log on to the website before continuing."
ErrorId = "AuthenticaionDenied"
ErrorId = "AuthenticationDenied"
Category = "AuthenticationError"
Cmdlet = $Cmdlet
}
ThrowError @errorParameter
}
{$loginReason -contains "AUTHORISATION_FAILED"} {
{ $loginReason -contains "AUTHORISATION_FAILED" } {
$errorParameter = @{
ExceptionType = "System.Net.Http.HttpRequestException"
Message = "The user could not be authorised."
Expand All @@ -58,8 +58,8 @@ function Test-ServerResponse {
}
ThrowError @errorParameter
}
{$loginReason -contains "OK"} {} # The login was OK
{$loginReason -contains "OUT"} {} # This indicates that person has in fact logged "out"
{ $loginReason -contains "OK" } { } # The login was OK
{ $loginReason -contains "OUT" } { } # This indicates that person has in fact logged "out"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions JiraPS/Public/Add-JiraGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ function Add-JiraGroupMember {
}
else {
$errorMessage = @{
Category = "ResourceExists"
ErrorId = "Adding [$user] to [$_group]"
Message = "User [$user] is already a member of group [$_group]"
Category = "ResourceExists"
ErrorId = "Adding [$user] to [$_group]"
Message = "User [$user] is already a member of group [$_group]"
}
WriteError @errorMessage
}
Expand Down
2 changes: 1 addition & 1 deletion JiraPS/Public/Add-JiraIssueLink.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Add-JiraIssueLink {
# .ExternalHelp ..\JiraPS-help.xml
# .ExternalHelp ..\JiraPS-help.xml
[CmdletBinding( SupportsShouldProcess )]
param(
[Parameter( Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName )]
Expand Down
16 changes: 8 additions & 8 deletions JiraPS/Public/Find-JiraFilter.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
function Find-JiraFilter {
# .ExternalHelp ..\JiraPS-help.xml
[CmdletBinding( DefaultParameterSetName='ByAccountId', SupportsPaging )]
[CmdletBinding( DefaultParameterSetName = 'ByAccountId', SupportsPaging )]
param(
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[string[]]$Name,

[Parameter(ParameterSetName='ByAccountId',ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName = 'ByAccountId', ValueFromPipelineByPropertyName)]
[string]$AccountId,

[Parameter(ParameterSetName='ByOwner',ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName = 'ByOwner', ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[ValidateScript(
{
Expand Down Expand Up @@ -61,11 +61,11 @@ function Find-JiraFilter {
[Object]
$Project,

[Validateset('description','favourite','favouritedCount','jql','owner','searchUrl','sharePermissions','subscriptions','viewUrl')]
[Validateset('description', 'favourite', 'favouritedCount', 'jql', 'owner', 'searchUrl', 'sharePermissions', 'subscriptions', 'viewUrl')]
[String[]]
$Fields = @('description','favourite','favouritedCount','jql','owner','searchUrl','sharePermissions','subscriptions','viewUrl'),
$Fields = @('description', 'favourite', 'favouritedCount', 'jql', 'owner', 'searchUrl', 'sharePermissions', 'subscriptions', 'viewUrl'),

[Validateset('description','favourite_count','is_favourite','id','name','owner')]
[Validateset('description', 'favourite_count', 'is_favourite', 'id', 'name', 'owner')]
[string]$Sort,

[System.Management.Automation.PSCredential]
Expand Down Expand Up @@ -116,7 +116,7 @@ function Find-JiraFilter {
$parameter[$_] = $PSCmdlet.PagingParameters.$_
}
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey('Name')) {
foreach($_name in $Name) {
foreach ($_name in $Name) {
$parameter['GetParameter']['filterName'] = $_name
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"

Expand Down
2 changes: 1 addition & 1 deletion JiraPS/Public/Get-JiraIssueAttachment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Get-JiraIssueAttachment {
if ($issueObj.Attachment) {
Write-Debug "[$($MyInvocation.MyCommand.Name)] Found Attachments on the Issue."
if ($FileName) {
$attachments = $issueObj.Attachment | Where-Object {$_.Filename -like $FileName}
$attachments = $issueObj.Attachment | Where-Object { $_.Filename -like $FileName }
}
else {
$attachments = $issueObj.Attachment
Expand Down
2 changes: 1 addition & 1 deletion JiraPS/Public/Get-JiraIssueAttachmentFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Get-JiraIssueAttachmentFile {
$iwParameters = @{
Uri = $_Attachment.Content
Method = 'Get'
Headers = @{"Accept" = $_Attachment.MimeType}
Headers = @{"Accept" = $_Attachment.MimeType }
OutFile = $filename
Credential = $Credential
}
Expand Down
9 changes: 4 additions & 5 deletions JiraPS/Public/Get-JiraIssueCreateMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ function Get-JiraIssueCreateMetadata {

$server = Get-JiraConfigServer -ErrorAction Stop

$resourceURi = "$server/rest/api/2/issue/createmeta/{0}/issuetypes/{1}"
$resourceURi = "$server/rest/api/2/issue/createmeta/{0}/issuetypes/{1}"
}

process {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$projectObj = Get-JiraProject -Project $Project -Credential $Credential -ErrorAction Stop
$issueTypeObj = $projectObj.IssueTypes | Where-Object -FilterScript {$_.Id -eq $IssueType -or $_.Name -eq $IssueType}
$issueTypeObj = $projectObj.IssueTypes | Where-Object -FilterScript { $_.Id -eq $IssueType -or $_.Name -eq $IssueType }

if ($null -eq $issueTypeObj.Id)
{
if ($null -eq $issueTypeObj.Id) {
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating parameters"
Expand Down Expand Up @@ -70,7 +69,7 @@ function Get-JiraIssueCreateMetadata {
$errorTarget = $Project
$errorItem = New-Object -TypeName System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $errorTarget
$errorItem.ErrorDetails = "No metadata found for project $Project and issueType $IssueType."
Throw $errorItem
throw $errorItem
}
}

Expand Down
2 changes: 1 addition & 1 deletion JiraPS/Public/Get-JiraIssueEditMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Get-JiraIssueEditMetadata {
$errorTarget = $Project
$errorItem = New-Object -TypeName System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $errorTarget
$errorItem.ErrorDetails = "No metadata found for project $Project and issueType $IssueType."
Throw $errorItem
throw $errorItem
}
}

Expand Down
Loading
Loading