Skip to content
Snippets Groups Projects
Commit 29bc3718 authored by Stefan Hauffe's avatar Stefan Hauffe
Browse files

OZG-7324: Add version checks

parent 52843348
No related branches found
No related tags found
No related merge requests found
......@@ -315,4 +315,23 @@ String getElementAccessToken() {
withCredentials([string(credentialsId: 'element-login-json', variable: 'LOGIN_JSON')]) {
return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token
}
}
Boolean isReleaseVersion(List versions) {
return matchRegexVersion(versions, RELEASE_REGEX)
}
Boolean isSnapshotVersion(List versions) {
return matchRegexVersion(versions, SNAPSHOT_REGEX)
}
Boolean matchRegexVersion(List versions, String regex) {
for (version in versions) {
println version
if ( !(version ==~ regex) ) {
return false
}
}
return true
}
\ No newline at end of file
......@@ -26,6 +26,16 @@ pipeline {
FAILED_STAGE = env.STAGE_NAME
dir('alfa-client') {
VERSION = getInfoPackageJsonVersion()
if(isReleaseBranch()){
if ( !isReleaseVersion([VERSION]) ) {
error("Keine Release Version für Branch ${env.BRANCH_NAME}.")
}
} else {
if ( !isSnapshotVersion([VERSION]) ) {
error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.")
}
}
}
}
}
......@@ -294,4 +304,23 @@ String getElementAccessToken() {
withCredentials([string(credentialsId: 'element-login-json', variable: 'LOGIN_JSON')]) {
return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token
}
}
Boolean isReleaseVersion(List versions) {
return matchRegexVersion(versions, RELEASE_REGEX)
}
Boolean isSnapshotVersion(List versions) {
return matchRegexVersion(versions, SNAPSHOT_REGEX)
}
Boolean matchRegexVersion(List versions, String regex) {
for (version in versions) {
println version
if ( !(version ==~ regex) ) {
return false
}
}
return true
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment