diff --git a/Jenkinsfile b/Jenkinsfile index 691142c386bd539e9be6e8debbd0a49deb011376..74af965187a2d82a7045194a3ab787772cc05d62 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,84 +52,16 @@ pipeline { FAILED_STAGE = env.STAGE_NAME VERSION = getRootPomVersion() def serverVersion = getParentPomVersion('alfa-server/pom.xml') - def clientVersion = getParentPomVersion('alfa-client/pom.xml') if(isReleaseBranch()){ - if ( !isReleaseVersion([VERSION, serverVersion, clientVersion]) ) { + if ( !isReleaseVersion([VERSION, serverVersion]) ) { error("Keine Release Version für Branch ${env.BRANCH_NAME}.") } } else { - if ( !isSnapshotVersion([VERSION, serverVersion, clientVersion]) ) { + if ( !isSnapshotVersion([VERSION, serverVersion]) ) { error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.") } } - - if( !isSameVersion([serverVersion, clientVersion], VERSION) ){ - error("Versionen sind nicht identisch") - } - } - } - } - - stage('Client') { - environment { - FORCE_COLOR = 'false' - } - steps { - script { - FAILED_STAGE=env.STAGE_NAME - - withNPM(npmrcConfig: 'npm-nexus-auth') { - sh 'npm --version' - sh 'node --version' - - dir('alfa-client') { - sh 'npm cache verify' - sh 'npm install' - - if (isMasterBranch()) { - withSonarQubeEnv('sonarqube-ozg-sh'){ - sh 'npm run ci-sonar' - } - } else { - sh 'npm run ci-test' - } - if (isReleaseBranch()) { - sh 'npm run ci-prodBuild' - } - else { - sh 'npm run ci-build' - } - } - } - } - } - // post { - // always{ - // junit testResults: 'alfa-client/test-report.xml', skipPublishingChecks: true - // } - // } - } - - stage('Build and push client container') { - steps { - script { - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - dir('alfa-client') { - IMAGE_TAG = buildVersionName() - - withNPM(npmrcConfig: 'npm-nexus-auth') { - sh 'npm run ci-build-alfa-client-container' - } - - withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { - sh 'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}' - - sh "docker tag docker.ozg-sh.de/alfa-client:build-latest docker.ozg-sh.de/alfa-client:${IMAGE_TAG}" - sh "docker push docker.ozg-sh.de/alfa-client:${IMAGE_TAG}" - } - } - } } } } @@ -138,7 +70,7 @@ pipeline { when { not { anyOf { - branch 'master' + branch 'main' branch 'release' } } @@ -155,7 +87,7 @@ pipeline { } } - stage('Build Server artefacts, build and push docker image') { + stage('Build Server artifacts, build and push docker image') { steps { script { FAILED_STAGE=env.STAGE_NAME @@ -163,10 +95,10 @@ pipeline { configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { sh 'mvn --version' - sh "mvn -s $MAVEN_SETTINGS -pl -alfa-client clean install" - sh "mvn --no-transfer-progress -s $MAVEN_SETTINGS -pl -alfa-client spring-boot:build-image -Dspring-boot.build-image.imageName=docker.ozg-sh.de/alfa:${IMAGE_TAG} -Dspring-boot.build-image.publish -Dmaven.wagon.http.retryHandler.count=3" + sh "mvn -s $MAVEN_SETTINGS clean install" + sh "mvn --no-transfer-progress -s $MAVEN_SETTINGS spring-boot:build-image -Dspring-boot.build-image.imageName=docker.ozg-sh.de/alfa:${IMAGE_TAG} -Dspring-boot.build-image.publish -Dmaven.wagon.http.retryHandler.count=3" - if (isMasterBranch()) { + if (isMainBranch()) { try { dir('alfa-service'){ withSonarQubeEnv('sonarqube-ozg-sh'){ @@ -194,7 +126,7 @@ pipeline { } configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { - sh 'mvn --no-transfer-progress -s $MAVEN_SETTINGS -pl -alfa-client -DskipTests deploy' + sh 'mvn --no-transfer-progress -s $MAVEN_SETTINGS -DskipTests deploy' sh "mvn -s $MAVEN_SETTINGS versions:revert" } } @@ -202,7 +134,7 @@ pipeline { stage('Tag and Push Docker Image') { when { anyOf { - branch 'master' + branch 'main' branch 'release' } } @@ -211,7 +143,7 @@ pipeline { script { FAILED_STAGE = env.STAGE_NAME - if (isMasterBranch()) { + if (isMainBranch()) { tagAndPushDockerImage('snapshot-latest') } else if (isReleaseBranch()) { @@ -239,29 +171,9 @@ pipeline { } } - stage('Test, build and deploy Alfa-Client Helm Chart') { - steps { - script { - FAILED_STAGE=env.STAGE_NAME - HELM_CHART_VERSION = buildVersionName() - dir('alfa-client') { - - sh "./run_helm_test.sh" - - dir('src/main/helm') { - - sh "helm package --version=${HELM_CHART_VERSION} ." - - deployHelmChart(HELM_CHART_VERSION, "alfa-client") - } - } - } - } - } - stage('Trigger Dev rollout') { when { - branch 'master' + branch 'main' } steps { script { @@ -291,49 +203,11 @@ pipeline { } } } - - stage ('Deploy SBOM to DependencyTrack') { - steps { - script { - IMAGE_TAG = buildVersionName() - - configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { - withCredentials([string(credentialsId: 'dependency-track-api-key', variable: 'API_KEY')]) { - - dir('alfa-server') { - catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh "mvn --no-transfer-progress -s $MAVEN_SETTINGS io.github.pmckeown:dependency-track-maven-plugin:upload-bom -Ddependency-track.apiKey=$API_KEY -Ddependency-track.projectVersion=${IMAGE_TAG} -Ddependency-track.dependencyTrackBaseUrl=https://dependency-track.ozg-sh.de" - } - } - } - } - } - } - } - - stage ('Trigger Barrierefreiheit Rollout') { - when { - branch 'barrierefreiheit-dev' - } - steps { - script { - FAILED_STAGE = env.STAGE_NAME - - cloneGitopsRepo() - - setNewBarrierefreiheitVersion() - - pushGitopsRepo() - - } - } - } - } post { failure { script { - if (isMasterBranch() || isReleaseBranch()) { + if (isMainBranch() || isReleaseBranch()) { sendFailureMessage() } } @@ -368,13 +242,9 @@ String validateBranchName(branchName) { } String buildVersionName() { - if (isReleaseBranch()) { return getRootPomVersion() } - if (isBarrierefreiheitBranch()) { - return "${getRootPomVersion()}-barrierefreiheit${validateBranchName(env.BRANCH_NAME)}${getCommitHash()}".replaceAll("_", "-") - } return "${getRootPomVersion()}-${validateBranchName(env.BRANCH_NAME)}${getCommitHash()}".replaceAll("_", "-") } @@ -426,7 +296,7 @@ Void sendFailureMessage() { "format": "org.matrix.custom.html", \ "formatted_body":"Alfa: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}""" - if (isMasterBranch()) { + if (isMainBranch()) { room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de" } else if (isReleaseBranch()) { @@ -455,16 +325,6 @@ Void setNewGitopsVersion(String environment) { def envFile = "${environment}/application/values/alfa-values.yaml" def commitMessage = "jenkins rollout ${environment} alfa version ${IMAGE_TAG}"; setNewAlfaGitopsVersion(envFile, commitMessage); - - envFile = "${environment}/application/values/alfa-client-values.yaml" - commitMessage = "jenkins rollout ${environment} alfa-client version ${IMAGE_TAG}"; - setNewAlfaClientGitopsVersion(envFile, commitMessage); -} - -Void setNewBarrierefreiheitVersion() { - def envFile = "dev/namespace/namespaces/by-barrierefreiheit-dev.yaml" - def commitMessage = "jenkins rollout ${IMAGE_TAG} for Barrierefreiheit Dev" - setNewAlfaGitopsVersion(envFile, commitMessage); } Void setNewAlfaGitopsVersion(String envFile, String commitMessage) { @@ -483,22 +343,6 @@ Void setNewAlfaGitopsVersion(String envFile, String commitMessage) { } } -Void setNewAlfaClientGitopsVersion(String envFile, String commitMessage) { - dir("gitops") { - def envVersions = readYaml file: envFile - - envVersions.alfa_client.image.tag = IMAGE_TAG - envVersions.alfa_client.helm.version = HELM_CHART_VERSION - - writeYaml file: envFile, data: envVersions, overwrite: true - - if (hasValuesFileChanged(envFile)) { - sh "git add ${envFile}" - sh "git commit -m '${commitMessage}'" - } - } -} - String getCommitHash() { return "-${env.GIT_COMMIT.take(7)}"; } @@ -511,12 +355,8 @@ Boolean isReleaseBranch() { return env.BRANCH_NAME == 'release' } -Boolean isMasterBranch() { - return env.BRANCH_NAME == 'master' -} - -Boolean isBarrierefreiheitBranch() { - return env.BRANCH_NAME == 'barrierefreiheit-dev' +Boolean isMainBranch() { + return env.BRANCH_NAME == 'main' } Boolean isReleaseVersion(List versions) {