From 4356ddff342bf08a551934bb3608cb88ae278674 Mon Sep 17 00:00:00 2001 From: ITS-s-autowinpkg Date: Mon, 16 Dec 2024 16:50:23 +0100 Subject: [PATCH] fix small bugs in jiraobserver --- WASP/Private/Invoke-JiraObserver.ps1 | 9 ++++++--- WASP/Private/Update-PullRequest.ps1 | 7 +++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/WASP/Private/Invoke-JiraObserver.ps1 b/WASP/Private/Invoke-JiraObserver.ps1 index 22bc5f9..10c1889 100644 --- a/WASP/Private/Invoke-JiraObserver.ps1 +++ b/WASP/Private/Invoke-JiraObserver.ps1 @@ -135,7 +135,7 @@ function Invoke-JiraObserver { # test → prod: PR nach prod, wenn nicht offen.Falls der PR schon gemerged wurde, wird der Jira State aktualisiert. } elseif ($IssuesCompareState[$key].StatusOld -eq "Testing" -and $IssuesCompareState[$key].Status -eq "Production") { # Es wird gecheckt ob ein offener oder gemergedter Pull Request nach prod existiert, falls nicht wird ein neuer PR erstellt - $UpdateJiraStateFile = Update-PullRequest -SourceBranch $DevBranch -DestinationBranch "test" -Software $key -DestinationName "Testing" + $UpdateJiraStateFile = Update-PullRequest -SourceBranch $DevBranch -DestinationBranch "prod" -Software $key -DestinationName "Production" # prod → dev: kein PR, neuer branch mit @ + random hash } elseif ($IssuesCompareState[$key].StatusOld -eq "Production" -and $IssuesCompareState[$key].Status -eq "Development") { @@ -148,13 +148,16 @@ function Invoke-JiraObserver { Write-Log -Message "New Repackaging Branch $RepackagingBranch created" -Severity 0 } $UpdateJiraStateFile = $true + # test -> dev: änderung wird im Jira State File geschrieben + } elseif ($IssuesCompareState[$key].StatusOld -eq "Testing" -and $IssuesCompareState[$key].Status -eq "Development") { + $UpdateJiraStateFile = $true # dev → prod: Error Message, da Testing übersprungen wurde } elseif (($IssuesCompareState[$key].StatusOld -eq "Development" -and $IssuesCompareState[$key].Status -eq "Production")) { Write-Log -Message "The status of the issue $key has changed from Development to Production without going through Testing. This Action is not allowed." -Severity 3 - continue + $UpdateJiraStateFile = $false } else { - continue + $UpdateJiraStateFile = $false } if ($UpdateJiraStateFile -eq $true) { # Der Jira State File wird aktualisiert für den entsprechenden Branch diff --git a/WASP/Private/Update-PullRequest.ps1 b/WASP/Private/Update-PullRequest.ps1 index 285f2bf..900ce13 100644 --- a/WASP/Private/Update-PullRequest.ps1 +++ b/WASP/Private/Update-PullRequest.ps1 @@ -43,21 +43,20 @@ function Update-PullRequest { $toBranch = $latestPullRequest.Details.base.ref if (($fromBranch -eq $SourceBranch) -and ($toBranch -eq $DestinationBranch) -and ($state -eq "open")) { - Write-Log "No action needed" -Severity 0 + Write-Log "No action needed. Pull Request from $SourceBranch to $DestinationBranch already exists" -Severity 1 return $false } else { $PullRequestTitle = "$Software to $DestinationName" $response = New-PullRequest -SourceRepo $packageGalleryRepo -SourceUser $gitHubOrganization -SourceBranch $SourceBranch -DestinationRepo $packageGalleryRepo -DestinationUser $gitHubOrganization -DestinationBranch $DestinationBranch -PullRequestTitle $PullRequestTitle -ErrorAction Stop - Start-Sleep -Seconds 6 + Start-Sleep -Seconds 4 if ($response.GetType().Name -ne "ErrorRecord") { - Write-Log -Message "New Pull Request $PullRequestTitle created" -Severity 0 + Write-Log -Message "New Pull Request $PullRequestTitle from $SourceBranch to $DestinationBranch created" -Severity 1 return $false } else { $ErrorDetails = ConvertFrom-Json $response.ErrorDetails $ErrorDetailsMessage = $ErrorDetails.Message $ErrorMessage = $ErrorDetails.errors.message if ($ErrorMessage -like "No commits between*") { - Write-Log -Message "No commits between $SourceBranch and $DestinationBranch" -Severity 0 return $true } else { Write-Log -Message "Error creating Pull Request: $ErrorDetailsMessage" -Severity 3