From 729f1b75b77ddf716642127145dc55dbc3579e1a Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Fri, 2 Oct 2020 09:42:36 +0100 Subject: [PATCH] HHH-14247 Fix automatic releease script, changelog.txt contains wrong Jira release url --- release/release.gradle | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/release/release.gradle b/release/release.gradle index 9a59f4853a..8b6304abc3 100644 --- a/release/release.gradle +++ b/release/release.gradle @@ -299,8 +299,6 @@ task changeLogFile( dependsOn: [releaseChecks] ) { } } - - task addVersionCommit( dependsOn: [changeLogFile] ) { group = "Release" description = "Adds a commit for the released version and push the changes to github" @@ -413,15 +411,14 @@ class ChangeLogFile { } def apiString = "https://hibernate.atlassian.net/rest/api/2/search/?jql=project=HHH%20AND%20fixVersion=${restReleaseVersion}%20order%20by%20issuetype%20ASC" def apiUrl = new URL( apiString ) - def releseNotes = new JsonSlurper().parse( apiUrl ) - - + def jsonReleaseNotes = new JsonSlurper().parse( apiUrl ) def releaseDate = new Date().format( 'MMMM dd, YYYY' ) - def versionId = releseNotes.issues.get( 0 ).fields.fixVersions.get( 0 ).id + def versionId = getVersionId( jsonReleaseNotes, restReleaseVersion ) + ReleaseNote releaseNotes = new ReleaseNote( releaseVersion, releaseDate, versionId ) def issuetype - releseNotes.issues.each { + jsonReleaseNotes.issues.each { issue -> if ( issuetype != issue.fields.issuetype.name ) { issuetype = issue.fields.issuetype.name @@ -433,6 +430,17 @@ class ChangeLogFile { releaseNotes.addEmptyLine() return releaseNotes.notes } + + private static getVersionId(jsonReleaseNotes, String restReleaseVersion) { + def fixVersions = jsonReleaseNotes.issues.get( 0 ).fields.fixVersions + + for ( def fixVersion : fixVersions ) { + if ( fixVersion.name.equals( restReleaseVersion ) ) { + return fixVersion.id + } + } + throw new GradleException( "Unable to determine the version id of the current release." ) + } } class ReleaseNote {