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
5d6e65dc
Commit
5d6e65dc
authored
1 year ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-4561 OZG-4565 adjust Jenkinsfile
parent
e46d18b9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Jenkinsfile
+28
-30
28 additions, 30 deletions
Jenkinsfile
with
28 additions
and
30 deletions
Jenkinsfile
+
28
−
30
View file @
5d6e65dc
...
...
@@ -6,7 +6,7 @@ pipeline {
}
environment
{
BLUE_OCEAN_URL
=
"https://jenkins.infra.ozg-cloud.systems/job/
goofy
/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
BLUE_OCEAN_URL
=
"https://jenkins.infra.ozg-cloud.systems/job/
alfa
/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
RELEASE_REGEX
=
/\d+.\d+.\d+/
SNAPSHOT_REGEX
=
/\d+.\d+.\d+-SNAPSHOT/
FAILED_STAGE
=
""
...
...
@@ -25,8 +25,8 @@ pipeline {
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
VERSION
=
getRootPomVersion
()
def
serverVersion
=
getParentPomVersion
(
'
goofy
-server/pom.xml'
)
def
clientVersion
=
getParentPomVersion
(
'
goofy
-client/pom.xml'
)
def
serverVersion
=
getParentPomVersion
(
'
alfa
-server/pom.xml'
)
def
clientVersion
=
getParentPomVersion
(
'
alfa
-client/pom.xml'
)
if
(
isReleaseBranch
()){
if
(
!
isReleaseVersion
([
VERSION
,
serverVersion
,
clientVersion
])
)
{
...
...
@@ -51,7 +51,7 @@ pipeline {
sh
'npm --version'
sh
'node --version'
dir
(
'
goofy
-client'
)
{
dir
(
'
alfa
-client'
)
{
sh
'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc'
sh
'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc'
...
...
@@ -81,7 +81,7 @@ pipeline {
}
// post {
// always{
// junit testResults: '
goofy
-client/test-report.xml', skipPublishingChecks: true
// junit testResults: '
alfa
-client/test-report.xml', skipPublishingChecks: true
// }
// }
}
...
...
@@ -93,7 +93,7 @@ pipeline {
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"
sh
"mvn -s $MAVEN_SETTINGS -pl -
alfa
-client clean install 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
())
{
try
{
...
...
@@ -134,7 +134,7 @@ pipeline {
}
configFileProvider
([
configFile
(
fileId:
'maven-settings'
,
variable:
'MAVEN_SETTINGS'
)])
{
sh
'mvn -s $MAVEN_SETTINGS -pl -
goofy
-client -DskipTests deploy'
sh
'mvn -s $MAVEN_SETTINGS -pl -
alfa
-client -DskipTests deploy'
}
}
}
...
...
@@ -145,7 +145,6 @@ pipeline {
branch
'release'
}
}
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
...
...
@@ -163,7 +162,7 @@ pipeline {
stage
(
'Test, build and deploy Helm Chart'
)
{
steps
{
script
{
FAILED_
GOOFY_
STAGE
=
env
.
STAGE_NAME
FAILED_STAGE
=
env
.
STAGE_NAME
HELM_CHART_VERSION
=
generateHelmChartVersion
()
dir
(
'src/main/helm'
)
{
...
...
@@ -189,7 +188,7 @@ pipeline {
cloneGitopsRepo
()
setNewDev
Goofy
Version
()
setNewDevVersion
()
pushGitopsRepo
()
}
}
...
...
@@ -200,14 +199,13 @@ pipeline {
when
{
branch
'release'
}
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
cloneGitopsRepo
()
setNewTest
Goofy
Version
()
setNewTestVersion
()
pushGitopsRepo
()
}
}
...
...
@@ -244,10 +242,10 @@ pipeline {
Void
deployHelmChart
(
String
helmChartVersion
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USERNAME'
,
passwordVariable:
'PASSWORD'
)]){
if
(
isReleaseBranch
())
{
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps -F file=@
goofy
-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps -F file=@
alfa
-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
}
else
{
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@
goofy
-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@
alfa
-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
}
if
(
result
!=
''
)
{
...
...
@@ -273,8 +271,8 @@ Void tagAndPushDockerImage(String newTag){
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/
goofy
:${IMAGE_TAG} docker.ozg-sh.de/
goofy
:${newTag}"
sh
"docker push docker.ozg-sh.de/
goofy
:${newTag}"
sh
"docker tag docker.ozg-sh.de/
alfa
:${IMAGE_TAG} docker.ozg-sh.de/
alfa
:${newTag}"
sh
"docker push docker.ozg-sh.de/
alfa
:${newTag}"
}
}
...
...
@@ -322,9 +320,9 @@ Void configureGit() {
Void
sendFailureMessage
()
{
def
room
=
''
def
data
=
"""{"msgtype":"m.text", \
"body":"
Goofy
: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
"body":"
Alfa
: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
"format": "org.matrix.custom.html", \
"formatted_body":"
Goofy
: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
"formatted_body":"
Alfa
: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
if
(
isMasterBranch
())
{
room
=
"!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de"
...
...
@@ -342,34 +340,34 @@ String getElementAccessToken() {
}
}
Void
setNewDev
Goofy
Version
()
{
setNewG
oofyG
itopsVersion
(
"dev"
)
Void
setNewDevVersion
()
{
setNewGitopsVersion
(
"dev"
)
}
Void
setNewTest
Goofy
Version
()
{
setNewG
oofyG
itopsVersion
(
"test"
)
Void
setNewTestVersion
()
{
setNewGitopsVersion
(
"test"
)
}
Void
setNewG
oofyG
itopsVersion
(
String
environment
)
{
Void
setNewGitopsVersion
(
String
environment
)
{
dir
(
"gitops"
)
{
def
envFile
=
"${environment}/application/values/
goofy
-values.yaml"
def
envFile
=
"${environment}/application/values/
alfa
-values.yaml"
def
envVersions
=
readYaml
file:
envFile
envVersions
.
goofy
.
image
.
tag
=
IMAGE_TAG
envVersions
.
goofy
.
helm
.
version
=
HELM_CHART_VERSION
envVersions
.
alfa
.
image
.
tag
=
IMAGE_TAG
envVersions
.
alfa
.
helm
.
version
=
HELM_CHART_VERSION
writeYaml
file:
envFile
,
data:
envVersions
,
overwrite:
true
if
(
has
Goofy
ValuesFileChanged
(
environment
))
{
if
(
hasValuesFileChanged
(
environment
))
{
sh
"git add ${envFile}"
sh
"git commit -m 'jenkins rollout ${environment}
goofy
version ${IMAGE_TAG}'"
sh
"git commit -m 'jenkins rollout ${environment}
alfa
version ${IMAGE_TAG}'"
}
}
}
Boolean
has
Goofy
ValuesFileChanged
(
String
environment
)
{
return
sh
(
script:
"git status | grep '${environment}/application/values/
goofy
-values.yaml'"
,
returnStatus:
true
)
==
env
.
SH_SUCCESS_STATUS_CODE
as
Integer
Boolean
hasValuesFileChanged
(
String
environment
)
{
return
sh
(
script:
"git status | grep '${environment}/application/values/
alfa
-values.yaml'"
,
returnStatus:
true
)
==
env
.
SH_SUCCESS_STATUS_CODE
as
Integer
}
Boolean
isReleaseBranch
()
{
...
...
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