Newer
Older
environment {
BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/blue/organizations/jenkins/goofy/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline"
RELEASE_REGEX = /\d+.\d+.\d+/
SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/
options {
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
// stage('Check Version') {
// steps {
// script {
// FAILED_STAGE = env.STAGE_NAME
// def rootPom = readMavenPom file: 'pom.xml'
// def rootVersion = rootPom.version
// def serverPom = readMavenPom file: 'goofy-server/pom.xml'
// def serverVersion = serverPom.parent.version
// def clientPom = readMavenPom file: 'goofy-client/pom.xml'
// def clientVersion = clientPom.parent.version
// if(env.BRANCH_NAME == 'release'){
// if ( !(rootVersion ==~ RELEASE_REGEX) || !(serverVersion ==~ RELEASE_REGEX) || !(clientVersion ==~ RELEASE_REGEX)) {
// error("Keine Release Version für Branch ${env.BRANCH_NAME}.")
// }
// } else {
// if ( !(rootVersion ==~ SNAPSHOT_REGEX) || !(serverVersion ==~ SNAPSHOT_REGEX) || !(clientVersion ==~ SNAPSHOT_REGEX)) {
// error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.")
// }
// }
// if( !(rootVersion == serverVersion && rootVersion == clientVersion)){
// error("Versionen sind nicht identisch")
// }
// }
// }
// }
// stage('Client') {
// steps {
// container("nodejs"){
// script {
// FAILED_STAGE=env.STAGE_NAME
// sh 'npm --version'
// dir('goofy-client') {
// sh 'echo "registry=http://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc'
// sh 'echo "_auth=amVua2luczpQaihzX0ZNNFU5ZC8=" >> ~/.npmrc'
// if (env.BRANCH_NAME == 'release') {
// sh 'npm run ci-prodBuild'
// }
// else {
// sh 'npm run ci-build'
// }
// try {
// if (env.BRANCH_NAME == 'master') {
// withSonarQubeEnv('sonarqube-ozg-sh'){
// sh 'npm run ci-sonar'
// }
// }
// } catch (Exception e) {
// unstable("SonarQube failed")
// }
// }
// }
// }
// }
// // post {
// // always{
// // junit testResults: 'goofy-client/test-report.xml', skipPublishingChecks: true
// // }
// // }
// }
// stage('Server') {
// steps {
// script {
// FAILED_STAGE=env.STAGE_NAME
// }
// container("maven-17"){
// configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
// sh 'mvn --version'
// sh 'mvn -s $MAVEN_SETTINGS -pl -goofy-client clean install spring-boot:build-image -Dmaven.wagon.http.retryHandler.count=3'
// }
// script {
// try {
// if (env.BRANCH_NAME == 'master') {
// dir('goofy-server'){
// withSonarQubeEnv('sonarqube-ozg-sh'){
// sh 'mvn sonar:sonar'
// }
// }
// }
// } catch (Exception e) {
// unstable("SonarQube failed")
// }
// }
// }
// }
// post {
// always{
// junit testResults: '**/target/surefire-reports/*.xml', skipPublishingChecks: true
// }
// }
// }
// stage('Push Docker image') {
// steps {
// script {
// FAILED_STAGE=env.STAGE_NAME
// def pom = readMavenPom file: 'pom.xml'
// def version = pom.version
// container("docker") {
// withCredentials([usernamePassword(credentialsId: 'jenkins-docker-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
// sh 'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}'
// sh "docker tag docker.ozg-sh.de/goofy:build-latest docker.ozg-sh.de/goofy:${env.BRANCH_NAME}-${version}"
// sh "docker push docker.ozg-sh.de/goofy:${env.BRANCH_NAME}-${version}"
// if (env.BRANCH_NAME == 'master') {
// sh 'docker tag docker.ozg-sh.de/goofy:build-latest docker.ozg-sh.de/goofy:e2e-test'
// sh 'docker push docker.ozg-sh.de/goofy:e2e-test'
// }
// }
// }
// }
// }
// }
stage('E2E-Tests(EA)') {
when {
}
steps {
script {
FAILED_STAGE=env.STAGE_NAME
}
script {
def branchName = env.BRANCH_NAME.replaceAll(/[^a-zA-Z0-9]+/, "").toLowerCase()
def namespace = 'e2e-${branchName}-dev'
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
sh 'helm upgrade --install --create-namespace goofy goofy --version 0.3.0-SNAPSHOT -f values.yaml --namespace ${namespace} --repo https://nexus.ozg-sh.de/repository/ozg-base-apps-snapshot --username ${USER} --password ${PASSWORD}'
}
// container("cypress") {
// dir('goofy-client') {
// sh 'npm run cypress:version'
// sh 'npm run cypress:ci-ea-run --BASE_URL=https://e2e.dev.ozg-sh.de'//TODO: durch eine dynamische url ersetzen
// }
// }
// container("k8s"){
// sh 'helm uninstall '
// }
}
post {
always {
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'goofy-client/apps/goofy-e2e/reports',
reportFiles: 'report_einheitlicher-ansprechpartner.html',
reportName: "Goofy E2E-Tests(EA)"
])
}
}
}
// stage('E2E-Tests') {
// when {
// branch 'master'
// }
// steps {
// script {
// FAILED_STAGE=env.STAGE_NAME
// }
// container("kubectl") {
// sh 'kubectl rollout restart deployment/goofy -n sh-e2e-dev'
// sh 'kubectl rollout status deployment/goofy -n sh-e2e-dev'
// sh 'kubectl rollout restart deployment/pluto -n sh-e2e-dev'
// sh 'kubectl rollout status deployment/pluto -n sh-e2e-dev'
// }
// container("cypress") {
// dir('goofy-client') {
// sh 'npm run cypress:version'
// sh 'npm run cypress:ci-run'
// }
// }
// }
// post {
// always {
// publishHTML (target: [
// allowMissing: false,
// alwaysLinkToLastBuild: false,
// keepAll: true,
// reportDir: 'goofy-client/apps/goofy-e2e/reports',
// reportFiles: 'report.html',
// reportName: "Goofy E2E-Tests"
// ])
// }
// }
// }
// stage('Deploy Maven Artifacts to Nexus') {
// when {
// anyOf {
// branch 'master'
// branch 'release'
// }
// }
// steps {
// script {
// FAILED_STAGE = env.STAGE_NAME
// }
// container('maven-17') {
// configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
// sh 'mvn -s $MAVEN_SETTINGS -pl -goofy-client -DskipTests deploy'
// }
// }
// }
// }
// stage('Deploy Goofy') {
// when {
// anyOf {
// branch 'master'
// branch 'release'
// }
// }
// steps {
// script {
// FAILED_STAGE = env.STAGE_NAME
// }
// container("docker") {
// script {
// withCredentials([usernamePassword(credentialsId: 'jenkins-docker-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
// sh 'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}'
// if (env.BRANCH_NAME == 'release') {
// sh 'docker tag docker.ozg-sh.de/goofy:build-latest docker.ozg-sh.de/goofy:latest'
// sh 'docker push docker.ozg-sh.de/goofy:latest'
// }
// if (env.BRANCH_NAME == 'master') {
// sh 'docker tag docker.ozg-sh.de/goofy:build-latest docker.ozg-sh.de/goofy:snapshot-latest'
// sh 'docker push docker.ozg-sh.de/goofy:snapshot-latest'
// }
// }
// }
// }
// container("kubectl"){
// script {
// if (env.BRANCH_NAME == 'release') {
// sh 'kubectl rollout restart deployment/goofy -n sh-kiel-test'
// sh 'kubectl rollout status deployment/goofy -n sh-kiel-test'
// sh 'kubectl rollout restart deployment/goofy -n sh-sl-test'
// sh 'kubectl rollout status deployment/goofy -n sh-sl-test'
// }
// if (env.BRANCH_NAME == 'master') {
// sh 'kubectl rollout restart deployment/goofy -n sh-kiel-dev'
// sh 'kubectl rollout status deployment/goofy -n sh-kiel-dev'
// }
// }
// }
// }
// }
// post {
// failure {
// script {
// if (env.BRANCH_NAME == 'master') {
// slackSend(color: "danger", message: "Goofy: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <${BLUE_OCEAN_URL}|${env.BUILD_NUMBER}>")
// }
// }
// }
// }