Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alfa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
alfa
Commits
4992d982
Commit
4992d982
authored
3 years ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-1784 jenkinsfile
parent
3f562269
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Jenkinsfile
+217
-20
217 additions, 20 deletions
Jenkinsfile
goofy-server/pom.xml
+9
-0
9 additions, 0 deletions
goofy-server/pom.xml
with
226 additions
and
20 deletions
Jenkinsfile
+
217
−
20
View file @
4992d982
def
FAILED_STAGE
def
E2E_FAILED
def
IMAGE_TAG
def
VERSION
pipeline
{
agent
{
...
...
@@ -13,6 +13,7 @@ pipeline {
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/
E2E_FAILED
=
[]
}
options
{
...
...
@@ -22,11 +23,113 @@ pipeline {
}
stages
{
stage
(
'Check Version'
)
{
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
def
rootPom
=
readMavenPom
file:
'pom.xml'
VERSION
=
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
(
!(
VERSION
==~
RELEASE_REGEX
)
||
!(
serverVersion
==~
RELEASE_REGEX
)
||
!(
clientVersion
==~
RELEASE_REGEX
))
{
error
(
"Keine Release Version für Branch ${env.BRANCH_NAME}."
)
}
}
else
{
if
(
!(
VERSION
==~
SNAPSHOT_REGEX
)
||
!(
serverVersion
==~
SNAPSHOT_REGEX
)
||
!(
clientVersion
==~
SNAPSHOT_REGEX
))
{
error
(
"Keine Snapshot Version für Branch ${env.BRANCH_NAME}."
)
}
}
if
(
!(
VERSION
==
serverVersion
&&
VERSION
==
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=https://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'
}
else
{
sh
'npm run ci-build'
}
sh
'npm run ci-test'
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
IMAGE_TAG
=
"${env.BRANCH_NAME}-${VERSION}"
println
(
"IMAGE_TAG: ${IMAGE_TAG}"
)
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 -Dspring-boot.build-image.imageName=docker.ozg-sh.de/goofy:$IMAGE_TAG -Dspring-boot.build-image.publish -Dmaven.wagon.http.retryHandler.count=3'
}
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
(
'Init k8s'
)
{
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
IMAGE_TAG
=
'latest'
}
container
(
"k8s"
)
{
configFileProvider
([
configFile
(
fileId:
'jenkins-kuby-kubeconfig'
,
variable:
'KUBE_CONFIG'
)])
{
...
...
@@ -35,11 +138,6 @@ pipeline {
}
sh
'helm version'
}
container
(
'nodejs'
)
{
dir
(
'goofy-client'
)
{
sh
'npm install --no-optional'
}
}
}
}
...
...
@@ -47,11 +145,7 @@ pipeline {
failFast
false
parallel
{
stage
(
'E2E-EA'
)
{
when
{
branch
'ozg-1784'
}
stage
(
'E2E-EA'
)
{
steps
{
script
{
def
stageName
=
env
.
STAGE_NAME
...
...
@@ -68,9 +162,8 @@ pipeline {
}
)
if
(
runTests
(
stageName
,
'einheitlicher-ansprechpartner'
)
!=
'0'
)
{
E2E_FAILED
=
true
E2E_FAILED
+
=
[
stageName
]
}
shutdownEnvironment
(
namespace
)
...
...
@@ -86,14 +179,18 @@ pipeline {
reportFiles:
'report.html'
,
reportName:
"Goofy E2E-Tests EA"
])
script
{
println
(
'post E2E-EA'
)
println
(
env
.
STAGE_NAME
)
if
(
E2E_FAILED
.
contains
(
env
.
STAGE_NAME
))
{
currentBuild
.
result
=
'FAILURE'
}
}
}
}
}
stage
(
'E2E-main'
)
{
when
{
branch
'ozg-1784'
}
steps
{
script
{
def
stageName
=
env
.
STAGE_NAME
...
...
@@ -111,7 +208,7 @@ pipeline {
)
if
(
runTests
(
stageName
,
'main-tests'
)
!=
'0'
)
{
E2E_FAILED
=
true
E2E_FAILED
+
=
[
stageName
]
}
shutdownEnvironment
(
namespace
)
...
...
@@ -127,6 +224,14 @@ pipeline {
reportFiles:
'report.html'
,
reportName:
"Goofy E2E-Tests main"
])
script
{
println
(
'post E2E-main'
)
println
(
env
.
STAGE_NAME
)
if
(
E2E_FAILED
.
contains
(
env
.
STAGE_NAME
))
{
currentBuild
.
result
=
'FAILURE'
}
}
}
}
}
...
...
@@ -135,12 +240,104 @@ pipeline {
always
{
script
{
if
(
E2E_FAILED
)
{
currentBuild
.
result
=
'FAILURE'
FAILED_STAGE
=
"E2E (${E2E_FAILED.join(', ')})"
}
}
}
}
}
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:${IMAGE_TAG} 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:${IMAGE_TAG} docker.ozg-sh.de/goofy:snapshot-latest'
sh
'docker push docker.ozg-sh.de/goofy:snapshot-latest'
}
}
}
}
}
}
stage
(
'Rollout (kiel-dev & ea-dev) | (kiel-test $ sl-test) Goofy'
)
{
when
{
anyOf
{
branch
'master'
branch
'release'
}
}
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
}
container
(
"k8s"
){
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'
sh
'kubectl rollout restart deployment/goofy -n sh-ea-dev'
sh
'kubectl rollout status deployment/goofy -n sh-ea-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}>"
)
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
goofy-server/pom.xml
+
9
−
0
View file @
4992d982
...
...
@@ -158,6 +158,15 @@
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<docker>
<publishRegistry>
<username>
${docker-username}
</username>
<password>
${docker-password}
</password>
<url>
${docker-url}
</url>
</publishRegistry>
</docker>
</configuration>
</plugin>
<plugin>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment