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

edit jenkins pipeline

parent 6f0d974c
Branches
Tags
No related merge requests found
def FAILED_STAGE
pipeline { pipeline {
agent { agent {
node { node {
...@@ -5,38 +7,69 @@ pipeline { ...@@ -5,38 +7,69 @@ pipeline {
} }
} }
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"
}
options { options {
timeout(time: 1, unit: 'HOURS') timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds() disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '5'))
} }
stages { stages {
stage('client build') { stage('Client') {
steps { steps {
script {
FAILED_STAGE=env.STAGE_NAME
}
container("nodejs"){ container("nodejs"){
sh 'npm --version' sh 'npm --version'
dir('goofy-client') { dir('goofy-client') {
sh 'npm install' sh 'npm install'
sh 'npm run build' sh 'npm run ci-build'
sh 'npm run test' sh 'npm run ci-test'
}
}
} }
post {
always{
junit testResults: 'goofy-client/junit.xml', skipPublishingChecks: true
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'goofy-client/coverage/lcov-report',
reportFiles: 'index.html',
reportName: "Goofy-Client code coverage"
])
} }
} }
} }
stage('server build') { stage('Server') {
steps { steps {
script {
FAILED_STAGE=env.STAGE_NAME
}
container("maven"){ container("maven"){
sh 'mvn --version' sh 'mvn --version'
sh 'mvn -pl -goofy-client clean install' sh 'mvn -pl -goofy-client clean install'
} }
} }
post {
always{
junit testResults: '**/target/surefire-reports/*.xml', skipPublishingChecks: true
}
}
} }
stage('openshift deploy') { stage('Openshift build') {
steps { steps {
script { script {
FAILED_STAGE=env.STAGE_NAME
def pom = readMavenPom file: 'pom.xml' def pom = readMavenPom file: 'pom.xml'
def version = pom.version def version = pom.version
...@@ -47,10 +80,91 @@ pipeline { ...@@ -47,10 +80,91 @@ pipeline {
} }
openshift.tag("goofy-builder:latest", "goofy-builder:${env.BRANCH_NAME}-${version}") openshift.tag("goofy-builder:latest", "goofy-builder:${env.BRANCH_NAME}-${version}")
if (env.BRANCH_NAME == 'master') {
def dc = openshift.selector('dc', 'goofy-e2e')
openshift.tag("goofy-builder:latest", "goofy-builder:e2e-latest")
dc.rollout().status()
}
}
}
}
}
}
stage('E2E-Test') {
when {
branch 'master'
}
steps {
script {
FAILED_STAGE=env.STAGE_NAME
}
container("cypress"){
sh 'npm --version'
dir('goofy-client') {
sh 'npm install'
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('Openshift deploy') {
when {
anyOf {
branch 'master';
branch 'release'
}
}
steps {
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}") openshift.tag("goofy-builder:${env.BRANCH_NAME}-${version}", "sh-kiel-dev/goofy:${env.BRANCH_NAME}-${version}")
} }
if (env.BRANCH_NAME == 'master') {
openshift.withProject('sh-kiel-dev') {
def dc = openshift.selector('deployments', 'goofy')
dc.rollout().status()
}
}
}
}
}
} }
} }
post {
success {
script {
if (env.BRANCH_NAME == 'master') {
slackSend(color: "good", message: "Goofy: Build Succeeded. Build-ID: <${BLUE_OCEAN_URL}|${env.BUILD_NUMBER}>")
}
}
}
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}>")
}
} }
} }
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
/dist /dist
/tmp /tmp
/out-tsc /out-tsc
junit.xml
/apps/goofy-e2e/reports
# dependencies # dependencies
/node_modules /node_modules
......
{
"baseUrl": "http://goofy-e2e-dev-tools.apps.lab.okd.local/",
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts",
"video": true,
"videosFolder": "./reports/videos",
"screenshotsFolder": "./reports/screenshots",
"chromeWebSecurity": false,
"reporter": "../../node_modules/cypress-mochawesome-reporter",
"reporterOptions": {
"html": false,
"json": true,
"quite": true,
"reportDir": "./reports/mochawesome-report",
"reportFilename": "report",
"overwrite": false
}
}
\ No newline at end of file
{ {
"baseUrl": "http://localhost:8080",
"fileServerFolder": ".", "fileServerFolder": ".",
"fixturesFolder": "./src/fixtures", "fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration", "integrationFolder": "./src/integration",
...@@ -6,7 +7,15 @@ ...@@ -6,7 +7,15 @@
"pluginsFile": "./src/plugins/index", "pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts", "supportFile": "./src/support/index.ts",
"video": true, "video": true,
"videosFolder": "./recordings/videos", "videosFolder": "./reports/videos",
"screenshotsFolder": "./recordings/screenshots", "screenshotsFolder": "./reports/screenshots",
"chromeWebSecurity": false "chromeWebSecurity": false,
"reporter": "../../node_modules/cypress-mochawesome-reporter",
"reporterOptions": {
"html": false,
"json": true,
"reportDir": "./reports/mochawesome-report",
"reportFilename": "report",
"overwrite": true
}
} }
\ No newline at end of file
*
\ No newline at end of file
import { MainPage } from '../page-abjects/main.po'; import { MainPage } from '../page-objects/main.po';
describe('goofy', () => { describe('goofy', () => {
const mainPage: MainPage = new MainPage(); const mainPage: MainPage = new MainPage();
......
...@@ -8,7 +8,7 @@ export class MainPage{ ...@@ -8,7 +8,7 @@ export class MainPage{
} }
public open(){ public open(){
cy.visit('http://localhost:4300/'); cy.visit('/');
} }
public getTitle(){ public getTitle(){
......
const fs = require("fs")
fs.rmdirSync("apps/goofy-e2e/reports/mochawesome-report", {recursive: true});
\ No newline at end of file
...@@ -15,3 +15,4 @@ ...@@ -15,3 +15,4 @@
// Import commands.js using ES2015 syntax: // Import commands.js using ES2015 syntax:
import './commands'; import './commands';
import 'cypress-mochawesome-reporter/register';
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"test:lib": "run-s \"ng -- test {1} --watchAll\" --", "test:lib": "run-s \"ng -- test {1} --watchAll\" --",
"test:debug:lib": "run-s \"ng -- test {1} --detectOpenHandles --watchAll\" --", "test:debug:lib": "run-s \"ng -- test {1} --detectOpenHandles --watchAll\" --",
"ci-build": "ng build", "ci-build": "ng build",
"ci-test": "jest test a", "ci-test": "jest test a --ci --coverage --testResultsProcessor='jest-junit'",
"lint": "nx workspace-lint && ng lint", "lint": "nx workspace-lint && ng lint",
"e2e": "ng e2e", "e2e": "ng e2e",
"affected:apps": "nx affected:apps", "affected:apps": "nx affected:apps",
...@@ -33,7 +33,14 @@ ...@@ -33,7 +33,14 @@
"dep-graph": "nx dep-graph", "dep-graph": "nx dep-graph",
"help": "nx help", "help": "nx help",
"favicon": "real-favicon generate favicon/faviconDescription.json favicon/faviconData.json src/favicon", "favicon": "real-favicon generate favicon/faviconDescription.json favicon/faviconData.json src/favicon",
"cypress:open": "npx cypress open --project apps/goofy-e2e" "cypress:open": "npx cypress open --project apps/goofy-e2e",
"cypress:run": "npx cypress run --project apps/goofy-e2e",
"cypress:version": "npx cypress version",
"cypress:merge-report": "mochawesome-merge apps/goofy-e2e/reports/mochawesome-report/*.json > apps/goofy-e2e/reports/report.json",
"cypress:generate-html": "marge apps/goofy-e2e/reports/report.json -f report -o apps/goofy-e2e/reports/",
"cypress:delete-old-reports": "node apps/goofy-e2e/src/support/delete-old-reports.ts",
"cypress:generate-report": "npm run cypress:merge-report ; npm run cypress:generate-html",
"cypress:ci-run": "npm run cypress:delete-old-reports ; npm run cypress:run -- --config-file ./cypress-ci.json ; test=$(echo \"$?\") ; npm run cypress:generate-report ; exit $test"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
...@@ -75,12 +82,14 @@ ...@@ -75,12 +82,14 @@
"@typescript-eslint/parser": "4.3.0", "@typescript-eslint/parser": "4.3.0",
"codelyzer": "~5.0.1", "codelyzer": "~5.0.1",
"cypress": "^5.6.0", "cypress": "^5.6.0",
"cypress-mochawesome-reporter": "^1.3.0",
"dotenv": "6.2.0", "dotenv": "6.2.0",
"eslint": "7.10.0", "eslint": "7.10.0",
"eslint-config-prettier": "6.0.0", "eslint-config-prettier": "6.0.0",
"eslint-plugin-cypress": "^2.10.3", "eslint-plugin-cypress": "^2.10.3",
"jest": "^26.2.2", "jest": "^26.2.2",
"jest-createspyobj": "^2.0.0", "jest-createspyobj": "^2.0.0",
"jest-junit": "^12.0.0",
"jest-preset-angular": "8.3.1", "jest-preset-angular": "8.3.1",
"prettier": "2.0.4", "prettier": "2.0.4",
"ts-jest": "26.4.0", "ts-jest": "26.4.0",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment