Skip to content

Commit 20b2e70

Browse files
authored
Log correct error message for wrong preview-branch value (#1249)
Fixed the error message in the log when given a wrong branch in parameter preview-branch of metadata.yml
1 parent ffd8347 commit 20b2e70

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Changed
88

99
### Fixed
10+
* Log correct error message for wrong preview-branch value ([#1249](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1249))
1011
* Fail the pipeline when no version specified for a deploy to Q, P ([#1248](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1248))
1112
* Fix Tailor deployment drifts for D, Q envs ([#1055](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1055))
1213

src/org/ods/orchestration/util/MROPipelineUtil.groovy

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,18 @@ class MROPipelineUtil extends PipelineUtil {
344344
this.logger.info("Since in WIP and no release branch exists (${this.project.gitReleaseBranch})" +
345345
"${repo.'preview-branch' ? ' and preview-branch has been configured' : ''}, " +
346346
"checking out branch ${repo.'preview-branch' ? repo.'preview-branch' : repo.defaultBranch} for repo ${repo.id}")
347-
scmResult.scm = checkoutBranchInRepoDir(repo, repo.'preview-branch' ? repo.'preview-branch' : repo.defaultBranch)
348-
scmResult.scmBranch = repo.'preview-branch' ? repo.'preview-branch' : repo.defaultBranch
347+
try {
348+
scmResult.scm = checkoutBranchInRepoDir(repo, repo.'preview-branch' ? repo.'preview-branch' : repo.defaultBranch)
349+
scmResult.scmBranch = repo.'preview-branch' ? repo.'preview-branch' : repo.defaultBranch
350+
} catch (ex) {
351+
if (repo.'preview-branch') {
352+
def errorMessage = "The preview branch configured for repository " +
353+
"\"${repo.name ? repo.name : GitUtil.buildFullRepoName(project.getKey(), repo.id)} " +
354+
"(preview-branch: ${repo.'preview-branch'})\" could not be found."
355+
throw new RuntimeException(errorMessage, ex)
356+
}
357+
throw ex
358+
}
349359
}
350360
}
351361
return scmResult

0 commit comments

Comments
 (0)