Skip to content
Snippets Groups Projects
Commit 430eaab4 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-533 jenkins on rancher

parent 80353786
No related branches found
No related tags found
No related merge requests found
def FAILED_STAGE
pipeline {
agent any
tools {
maven 'maven3'
jdk 'jdk11'
nodejs 'node14'
agent {
node {
label 'jenkins-worker'
}
//{
// node {
// label 'goofy'
//}
//}
environment {
//BLUE_OCEAN_URL = "https://jenkins-dev-tools.apps.lab.okd.local/blue/organizations/jenkins/OZG%2Fgoofy/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline"
BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/blue/organizations/jenkins/OZG%2Fgoofy/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline"
}
options {
......@@ -27,13 +16,16 @@ pipeline {
stages {
stage('Client') {
steps {
// container("nodejs"){
container("nodejs"){
script {
FAILED_STAGE=env.STAGE_NAME
sh 'npm --version'
dir('goofy-client') {
sh 'npm install'
sh 'echo "registry=http://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc'
sh 'echo "_auth=amVua2luczpQaihzX0ZNNFU5ZC8=" >> ~/.npmrc'
sh 'npm install --no-optional'
if (env.BRANCH_NAME == 'release') {
sh 'npm run ci-prodBuild'
......@@ -43,15 +35,9 @@ pipeline {
}
sh 'npm run ci-test'
if (env.BRANCH_NAME == 'master') {
withSonarQubeEnv('sonarqube'){
sh 'npm run ci-sonar'
}
}
}
}
//gi}
}
post {
always{
......@@ -66,19 +52,9 @@ pipeline {
FAILED_STAGE=env.STAGE_NAME
}
container("maven-11"){
configFileProvider([configFile(fileId: '9aac2fac-7d8d-4128-846b-0a61951df703', variable: 'MAVEN_SETTINGS')]) {
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn --version'
sh 'mvn -s $MAVEN_SETTINGS -pl -goofy-client clean install'
script {
if (env.BRANCH_NAME == 'master') {
dir('goofy-server'){
withSonarQubeEnv('sonarqube'){
sh 'mvn sonar:sonar'
}
}
}
}
sh 'mvn -s $MAVEN_SETTINGS -pl -goofy-client clean install spring-boot:build-image -Dspring-boot.build-image.imageName=docker.ozg-sh.de/goofy:build-latest'
}
}
}
......@@ -89,32 +65,23 @@ pipeline {
}
}
stage('Openshift build') {
stage('Push Docker image') {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
def pom = readMavenPom file: 'pom.xml'
def version = pom.version
openshift.withCluster() {
openshift.withProject() {
dir('goofy-server') {
openshift.startBuild("goofy-builder", "--from-dir=.", "--follow", "--wait")
}
openshift.tag("goofy-builder:build-latest", "goofy-builder:${env.BRANCH_NAME}-${version}")
container("docker") {
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') {
openshift.tag("goofy-builder:${env.BRANCH_NAME}-${version}", "goofy-builder:latest")
}
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') {
def dc = openshift.selector('dc', 'goofy-e2e')
openshift.tag("goofy-builder:${env.BRANCH_NAME}-${version}", "goofy-builder:snapshot-latest")
openshift.tag("goofy-builder:${env.BRANCH_NAME}-${version}", "goofy-builder:e2e-latest")
dc.rollout().status()
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'
}
}
}
......@@ -122,7 +89,7 @@ pipeline {
}
}
stage('E2E-Test') {
stage('E2E-Tests') {
when {
branch 'master'
}
......@@ -130,10 +97,17 @@ pipeline {
script {
FAILED_STAGE=env.STAGE_NAME
}
container("kubectl") {
sh 'kubectl rollout restart deployment/goofy -n sh-kiel-e2e'
sh 'kubectl rollout status deployment/goofy -n sh-kiel-e2e'
sh 'kubectl rollout restart deployment/pluto -n sh-kiel-e2e'
sh 'kubectl rollout status deployment/pluto -n sh-kiel-e2e'
}
container("cypress") {
sh 'npm --version'
dir('goofy-client') {
sh 'npm install'
sh 'npm run cypress:version'
sh 'npm run cypress:ci-run'
}
......@@ -153,7 +127,7 @@ pipeline {
}
}
stage('nexus deploy'){
stage('Deploy Maven Artifacts to Nexus') {
when {
anyOf {
branch 'master'
......@@ -165,55 +139,52 @@ pipeline {
FAILED_STAGE = env.STAGE_NAME
}
container('maven-11') {
configFileProvider([configFile(fileId: '9aac2fac-7d8d-4128-846b-0a61951df703', variable: 'MAVEN_SETTINGS')]) {
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn -s $MAVEN_SETTINGS -pl -goofy-client -DskipTests deploy'
}
}
}
}
stage('Openshift deploy') {
stage('Deploy Goofy') {
when {
anyOf {
branch 'master';
branch 'master'
branch 'release'
}
}
steps {
container("docker") {
script {
FAILED_STAGE=env.STAGE_NAME
def pom = readMavenPom file: 'pom.xml'
def version = pom.version
openshift.withCluster() {
openshift.withProject() {
openshift.tag("goofy-builder:${env.BRANCH_NAME}-${version}", "sh-kiel-dev/goofy:${env.BRANCH_NAME}-${version}")
if (env.BRANCH_NAME == 'master') {
openshift.tag("goofy-builder:snapshot-latest", "sh-kiel-dev/goofy:snapshot-latest")
}
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') {
openshift.tag("goofy-builder:latest", "sh-kiel-dev/goofy:latest")
}
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') {
openshift.withProject('sh-kiel-dev') {
def dc = openshift.selector('deployments', 'goofy')
dc.rollout().status()
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'
}
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}>")
}
}
}
......
{
"baseUrl": "http://goofy-e2e-dev-tools.apps.lab.okd.local/",
"baseUrl": "https://kiel.e2e.ozg-sh.de",
"env": {
"dbUrl": "e2e-test:sadf3tr%2Cmb4%25.@172.30.190.222:27017",
"dbUrl": "e2e-test:JkejFfXD@192.168.101.11:30423",
"database": "sh-kiel-e2e-test",
"keycloakRealm": "sh-kiel-dev",
"keycloakUrl": "https://sso.ozg-sh.de/",
......
......@@ -93,7 +93,6 @@
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"codelyzer": "6.0.1",
"cypress": "^6.6.0",
"cypress-mochawesome-reporter": "^1.3.0",
"dotenv": "6.2.0",
"eslint": "7.10.0",
......@@ -111,5 +110,8 @@
"ts-node": "9.1.1",
"tslint": "6.1.3",
"typescript": "^4.0.7"
},
"optionalDependencies": {
"cypress": "^6.6.0"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment