From 5073b386eb7f656e742c600529d7c05071aee6bd Mon Sep 17 00:00:00 2001 From: brais <26645694+braisvq1996@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:47:42 +0200 Subject: [PATCH] Release 4.5.4 (#1142) --- CHANGELOG.md | 9 +++++ src/org/ods/orchestration/DeployStage.groovy | 39 ++++++++++++------- .../ods/orchestration/FinalizeStage.groovy | 1 + .../orchestration/usecase/JiraUseCase.groovy | 9 ++++- .../orchestration/FinalizeStageSpec.groovy | 23 +++++++++++ .../usecase/JiraUseCaseSpec.groovy | 25 +++++++----- 6 files changed, 80 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f17d7cb07..2d165dd20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,15 @@ ### Fixed * Fix Tailor deployment drifts for D, Q envs ([#1055](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1055)) +## [4.5.4] - 2024-07-17 + +### Changed +* In test results, labels not related to execution persist ([#1138](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1138)) + +### Fixed +* Fix excluded ods-infra components failing on deploy stage ([#1139](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1139)) +* Fix Finalize stage for ods-library components ([#1140](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1140)) + ## [4.5.3] - 2024-07-08 ### Fixed diff --git a/src/org/ods/orchestration/DeployStage.groovy b/src/org/ods/orchestration/DeployStage.groovy index d2f3ac035..76f2edf4a 100644 --- a/src/org/ods/orchestration/DeployStage.groovy +++ b/src/org/ods/orchestration/DeployStage.groovy @@ -142,23 +142,34 @@ class DeployStage extends Stage { } private void loadOdsInfraTypeData (Map repo) { - if (repo.data == null) { repo.data = [:] } ILogger logger = ServiceRegistry.instance.get(Logger) - def steps = ServiceRegistry.instance.get(PipelineSteps) + if (repo.include) { + if (repo.data == null) { + repo.data = [:] + } + def steps = ServiceRegistry.instance.get(PipelineSteps) + + // collect test results + if (repo.data.tests == null) { + repo.data.tests = [:] + } + repo.data.tests << [installation: getTestResults(steps, repo, Project.TestType.INSTALLATION)] - // collect test results - if (repo.data.tests == null) { repo.data.tests = [:] } - repo.data.tests << [installation: getTestResults(steps, repo, Project.TestType.INSTALLATION)] - - // collect log data - if (repo.data.logs == null) { repo.data.logs = [:] } - repo.data.logs << [created: getLogReports(steps, repo, Project.LogReportType.CHANGES)] - repo.data.logs << [target: getLogReports(steps, repo, Project.LogReportType.TARGET)] - repo.data.logs << [state: getLogReports(steps, repo, Project.LogReportType.STATE)] - if (repo.data.logs.state.content) { - repo.data.logs.state.content = JsonOutput.prettyPrint(repo.data.logs.state.content[0]) + // collect log data + if (repo.data.logs == null) { + repo.data.logs = [:] + } + repo.data.logs << [created: getLogReports(steps, repo, Project.LogReportType.CHANGES)] + repo.data.logs << [target: getLogReports(steps, repo, Project.LogReportType.TARGET)] + repo.data.logs << [state: getLogReports(steps, repo, Project.LogReportType.STATE)] + if (repo.data.logs.state.content) { + repo.data.logs.state.content = JsonOutput.prettyPrint(repo.data.logs.state.content[0]) + } else { + logger.warn("No log state for ${repo.data} found!") + } } else { - logger.warn("No log state for ${repo.data} found!") + logger.debug("Include flag is set to false so not loading ODS Infrastructure/Configuration Management " + + "component type data for '${repo.id}'") } } diff --git a/src/org/ods/orchestration/FinalizeStage.groovy b/src/org/ods/orchestration/FinalizeStage.groovy index 685960b40..59bfb9878 100644 --- a/src/org/ods/orchestration/FinalizeStage.groovy +++ b/src/org/ods/orchestration/FinalizeStage.groovy @@ -204,6 +204,7 @@ class FinalizeStage extends Stage { if (repo.include) { def repoType = repo.type?.toLowerCase() if ((repoType != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_TEST && + repoType != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_LIB && repoType != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_INFRA && repoType != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_SAAS_SERVICE)) { repoIntegrateTasks << [(repo.id): { doIntegrateIntoMainBranches(steps, repo, git) }] diff --git a/src/org/ods/orchestration/usecase/JiraUseCase.groovy b/src/org/ods/orchestration/usecase/JiraUseCase.groovy index 0e25dee6a..08f9ec57f 100644 --- a/src/org/ods/orchestration/usecase/JiraUseCase.groovy +++ b/src/org/ods/orchestration/usecase/JiraUseCase.groovy @@ -85,6 +85,9 @@ class JiraUseCase { // Handle Jira test issues for which a corresponding test exists in testResults def matchedHandler = { result -> result.each { testIssue, testCase -> + // Remove all the results from preceding executions + this.jira.removeLabelsFromIssue(testIssue.key, TestIssueLabels.values().collect() { it.name() }) + def issueLabels = [TestIssueLabels.Succeeded as String] if (testCase.error) { issueLabels = [TestIssueLabels.Error as String] @@ -98,14 +101,16 @@ class JiraUseCase { issueLabels = [TestIssueLabels.Skipped as String] } - this.jira.setIssueLabels(testIssue.key, issueLabels) + this.jira.addLabelsToIssue(testIssue.key, issueLabels) } } // Handle Jira test issues for which no corresponding test exists in testResults def unmatchedHandler = { result -> result.each { testIssue -> - this.jira.setIssueLabels(testIssue.key, [TestIssueLabels.Missing as String]) + // Remove all the results from preceding executions + this.jira.removeLabelsFromIssue(testIssue.key, TestIssueLabels.values().collect() { it.name() }) + this.jira.addLabelsToIssue(testIssue.key, [TestIssueLabels.Missing as String]) } } diff --git a/test/groovy/org/ods/orchestration/FinalizeStageSpec.groovy b/test/groovy/org/ods/orchestration/FinalizeStageSpec.groovy index 538c74949..4910a6376 100644 --- a/test/groovy/org/ods/orchestration/FinalizeStageSpec.groovy +++ b/test/groovy/org/ods/orchestration/FinalizeStageSpec.groovy @@ -125,4 +125,27 @@ class FinalizeStageSpec extends SpecHelper { 1 * gitService.createTag(project.targetTag) 1 * gitService.pushForceBranchWithTags(project.gitReleaseBranch) } + + def "integrateIntoMainBranchRepos if repo of type is #type"() { + given: + def repos = project.data.metadata.repositories + repos.each { repo -> + repo.type = type + } + + def finalStageNotInstallable = Spy(new FinalizeStage(script, project, repos)) + + when: + finalStageNotInstallable.integrateIntoMainBranchRepos(steps, gitService) + + then: + 0 * finalStageNotInstallable.doIntegrateIntoMainBranches(_) + + where: + type | _ + 'ods-test' | _ + 'ods-library' | _ + 'ods-infra' | _ + 'ods-saas-service' | _ + } } diff --git a/test/groovy/org/ods/orchestration/usecase/JiraUseCaseSpec.groovy b/test/groovy/org/ods/orchestration/usecase/JiraUseCaseSpec.groovy index 3fd01e802..9fe65500c 100644 --- a/test/groovy/org/ods/orchestration/usecase/JiraUseCaseSpec.groovy +++ b/test/groovy/org/ods/orchestration/usecase/JiraUseCaseSpec.groovy @@ -48,24 +48,29 @@ class JiraUseCaseSpec extends SpecHelper { usecase.applyXunitTestResultsAsTestIssueLabels(testIssues, testResults) then: - 1 * jira.setIssueLabels("JIRA-1", ["Succeeded"]) - 0 * jira.setIssueLabels("JIRA-1", _) + 1 * jira.removeLabelsFromIssue("JIRA-1", ['Error', 'Failed', 'Missing', 'Skipped', 'Succeeded']) + 1 * jira.addLabelsToIssue("JIRA-1", ["Succeeded"]) + 0 * jira.addLabelsToIssue("JIRA-1", _) then: - 1 * jira.setIssueLabels("JIRA-2", ["Error"]) - 0 * jira.setIssueLabels("JIRA-2", _) + 1 * jira.removeLabelsFromIssue("JIRA-2", ['Error', 'Failed', 'Missing', 'Skipped', 'Succeeded']) + 1 * jira.addLabelsToIssue("JIRA-2", ["Error"]) + 0 * jira.addLabelsToIssue("JIRA-2", _) then: - 1 * jira.setIssueLabels("JIRA-3", ["Failed"]) - 0 * jira.setIssueLabels("JIRA-3", _) + 1 * jira.removeLabelsFromIssue("JIRA-3", ['Error', 'Failed', 'Missing', 'Skipped', 'Succeeded']) + 1 * jira.addLabelsToIssue("JIRA-3", ["Failed"]) + 0 * jira.addLabelsToIssue("JIRA-3", _) then: - 1 * jira.setIssueLabels("JIRA-4", ["Skipped"]) - 0 * jira.setIssueLabels("JIRA-4", _) + 1 * jira.removeLabelsFromIssue("JIRA-4", ['Error', 'Failed', 'Missing', 'Skipped', 'Succeeded']) + 1 * jira.addLabelsToIssue("JIRA-4", ["Skipped"]) + 0 * jira.addLabelsToIssue("JIRA-4", _) then: - 1 * jira.setIssueLabels("JIRA-5", ["Missing"]) - 0 * jira.setIssueLabels("JIRA-5", _) + 1 * jira.removeLabelsFromIssue("JIRA-5",['Error', 'Failed', 'Missing', 'Skipped', 'Succeeded']) + 1 * jira.addLabelsToIssue("JIRA-5", ["Missing"]) + 0 * jira.addLabelsToIssue("JIRA-5", _) } def "check Jira issue matches test case"() {