Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend-clients
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
frontend-clients
Commits
f90f4f66
Commit
f90f4f66
authored
2 years ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-3140 run on new jenkins
parent
c057e201
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
+167
-177
167 additions, 177 deletions
Jenkinsfile
with
167 additions
and
177 deletions
Jenkinsfile
+
167
−
177
View file @
f90f4f66
pipeline
{
agent
{
node
{
label
'jenkins-
worker
'
label
'jenkins-
build-agent
'
}
}
...
...
@@ -54,7 +54,6 @@ pipeline {
}
stage
(
'Client'
)
{
steps
{
container
(
"nodejs"
){
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
...
...
@@ -64,7 +63,7 @@ pipeline {
sh
'echo "_auth=amVua2luczpQaihzX0ZNNFU5ZC8=" >> ~/.npmrc'
sh
'npm cache verify'
sh
'npm install
--no-optional
--legacy-peer-deps'
sh
'npm install --legacy-peer-deps'
if
(
env
.
BRANCH_NAME
==
'release'
)
{
sh
'npm run ci-prodBuild'
...
...
@@ -87,7 +86,6 @@ pipeline {
}
}
}
}
// post {
// always{
// junit testResults: 'goofy-client/test-report.xml', skipPublishingChecks: true
...
...
@@ -100,7 +98,6 @@ pipeline {
FAILED_STAGE
=
env
.
STAGE_NAME
IMAGE_TAG
=
generateImageTag
()
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"
...
...
@@ -119,7 +116,6 @@ pipeline {
}
}
}
}
post
{
always
{
junit
testResults:
'**/target/surefire-reports/*.xml'
,
skipPublishingChecks:
true
...
...
@@ -131,9 +127,8 @@ pipeline {
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
E2E_FAILED
=
""
}
container
(
"k8s"
)
{
configFileProvider
([
configFile
(
fileId:
'jenkins-kuby-kubeconfig'
,
variable:
'KUBE_CONFIG'
)])
{
configFileProvider
([
configFile
(
fileId:
'kubeconfig-old-dev-cluster'
,
variable:
'KUBE_CONFIG'
)])
{
sh
'mkdir ~/.kube'
sh
'cp ${KUBE_CONFIG} ~/.kube/config'
}
...
...
@@ -142,7 +137,6 @@ pipeline {
sh
'helm version'
}
setAnsibleKubeConfig
()
}
}
stage
(
'Deploy Maven Artifacts to Nexus'
)
{
...
...
@@ -156,13 +150,12 @@ pipeline {
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
(
'Tag and Push Docker Image'
)
{
when
{
anyOf
{
...
...
@@ -187,7 +180,6 @@ pipeline {
stage
(
'Test, build and deploy Helm Chart'
)
{
steps
{
container
(
'k8s'
)
{
script
{
FAILED_GOOFY_STAGE
=
env
.
STAGE_NAME
HELM_CHART_VERSION
=
generateHelmChartVersion
()
...
...
@@ -204,7 +196,6 @@ pipeline {
}
}
}
}
stage
(
'Trigger Dev rollout'
)
{
when
{
...
...
@@ -236,10 +227,11 @@ pipeline {
script
{
def
stageName
=
env
.
STAGE_NAME
def
bezeichner
=
generateBezeichner
(
stageName
)
def
dbPort
=
27018
startEnvironment
(
bezeichner
,
stageName
,
IMAGE_TAG
,
true
,
HELM_CHART_VERSION
)
startEnvironment
(
bezeichner
,
stageName
,
IMAGE_TAG
,
true
,
HELM_CHART_VERSION
,
'sh'
,
dbPort
)
def
testResult
=
runTests
(
stageName
,
bezeichner
,
'einheitlicher-ansprechpartner'
)
def
testResult
=
runTests
(
stageName
,
bezeichner
,
'einheitlicher-ansprechpartner'
,
'sh'
,
dbPort
)
if
(
env
.
BRANCH_NAME
!=
'master'
)
{
deleteKopStack
(
bezeichner
,
stageName
)
...
...
@@ -264,10 +256,11 @@ pipeline {
script
{
def
stageName
=
env
.
STAGE_NAME
def
bezeichner
=
generateBezeichner
(
stageName
)
def
dbPort
=
27019
startEnvironment
(
bezeichner
,
stageName
,
IMAGE_TAG
,
false
,
HELM_CHART_VERSION
)
startEnvironment
(
bezeichner
,
stageName
,
IMAGE_TAG
,
false
,
HELM_CHART_VERSION
,
'sh'
,
dbPort
)
def
testResult
=
runTests
(
stageName
,
bezeichner
,
'main-tests'
)
def
testResult
=
runTests
(
stageName
,
bezeichner
,
'main-tests'
,
'sh'
,
dbPort
)
if
(
env
.
BRANCH_NAME
!=
'master'
)
{
deleteKopStack
(
bezeichner
,
stageName
)
...
...
@@ -332,10 +325,10 @@ pipeline {
Void
deployHelmChart
(
String
helmChartVersion
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USERNAME'
,
passwordVariable:
'PASSWORD'
)]){
if
(
env
.
BRANCH_NAME
==
'release'
)
{
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD http://nexus.
dev-tools:8081
/service/rest/v1/components?repository=ozg-base-apps -F file=@goofy-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD http
s
://nexus.
ozg-sh.de
/service/rest/v1/components?repository=ozg-base-apps -F file=@goofy-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
}
else
{
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD http://nexus.
dev-tools:8081
/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@goofy-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
result
=
sh
script:
'''curl -u $USERNAME:$PASSWORD http
s
://nexus.
ozg-sh.de
/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@goofy-'''
+
helmChartVersion
+
'''.tgz'''
,
returnStdout:
true
}
if
(
result
!=
''
)
{
...
...
@@ -358,7 +351,6 @@ String generateHelmChartVersion() {
}
Void
tagAndPushDockerImage
(
String
newTag
){
container
(
"docker"
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-docker-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
sh
'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}'
...
...
@@ -366,7 +358,6 @@ Void tagAndPushDockerImage(String newTag){
sh
"docker push docker.ozg-sh.de/goofy:${newTag}"
}
}
}
String
generateImageTag
()
{
def
imageTag
=
"${env.BRANCH_NAME}-${VERSION}"
...
...
@@ -378,7 +369,7 @@ String generateImageTag() {
return
imageTag
}
Void
startEnvironment
(
String
bezeichner
,
String
stage
,
String
imageTag
,
Boolean
isEa
,
String
chartVersion
)
{
Void
startEnvironment
(
String
bezeichner
,
String
stage
,
String
imageTag
,
Boolean
isEa
,
String
chartVersion
,
String
bundesland
,
dbPort
)
{
setupAnsible
(
imageTag
,
stage
,
isEa
,
chartVersion
)
try
{
...
...
@@ -388,8 +379,10 @@ Void startEnvironment(String bezeichner, String stage, String imageTag, Boolean
}
rolloutKopStack
(
bezeichner
,
stage
)
addKeycloakGroups
(
bezeichner
,
stage
)
addKeycloakUser
(
bezeichner
,
stage
)
addKeycloakGroups
(
bezeichner
,
stage
,
bundesland
)
addKeycloakUser
(
bezeichner
,
stage
,
bundesland
)
exposeDatenbank
(
"${bundesland}-${bezeichner}-dev"
,
dbPort
)
exposeElasticSearch
()
}
Void
setupAnsible
(
String
imageTag
,
String
stage
,
Boolean
isEa
,
String
chartVersion
)
{
...
...
@@ -409,13 +402,11 @@ Void setupAnsible(String imageTag, String stage, Boolean isEa, String chartVersi
}
Void
setAnsibleKubeConfig
()
{
container
(
"ansible"
)
{
configFileProvider
([
configFile
(
fileId:
'jenkins-kuby-kubeconfig'
,
variable:
'KUBE_CONFIG'
)])
{
configFileProvider
([
configFile
(
fileId:
'kubeconfig-old-dev-cluster'
,
variable:
'KUBE_CONFIG'
)])
{
sh
'mkdir ~/.kube'
sh
'cp ${KUBE_CONFIG} ~/.kube/config'
}
}
}
Void
checkoutProvisioningRepo
(
String
stage
=
""
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-gitea-access-token'
,
passwordVariable:
'TOKEN'
,
usernameVariable:
'USER'
)])
{
...
...
@@ -514,7 +505,6 @@ Void setPlutoDatabasePassword(String stage) {
}
Void
rolloutKopStack
(
String
bezeichner
,
String
stage
)
{
container
(
"ansible"
)
{
dir
(
"${stage}/provisioning"
)
{
def
ansibleVars
=
"""{"k8s_context":"ozg-dev", \
"kop_env":"dev", \
...
...
@@ -534,10 +524,8 @@ Void rolloutKopStack(String bezeichner, String stage) {
}
}
}
}
Void
addKeycloakGroups
(
String
bezeichner
,
String
stage
)
{
container
(
"ansible"
)
{
Void
addKeycloakGroups
(
String
bezeichner
,
String
stage
,
String
bundesland
)
{
def
groupFiles
=
sh
(
script:
'ls goofy-client/apps/goofy-e2e/src/fixtures/group'
,
returnStdout:
true
)
groupFiles
.
split
(
"\\n"
).
each
{
group
->
...
...
@@ -545,7 +533,7 @@ Void addKeycloakGroups(String bezeichner, String stage) {
def
ansibleVars
=
"""{"k8s_context":"ozg-dev", \
"kop_env":"dev", \
"keycloak_realm":"
sh
-${bezeichner}-dev", \
"keycloak_realm":"
${bundesland}
-${bezeichner}-dev", \
"group":${groupJson}
}"""
...
...
@@ -559,10 +547,8 @@ Void addKeycloakGroups(String bezeichner, String stage) {
}
}
}
}
Void
addKeycloakUser
(
String
bezeichner
,
String
stage
)
{
container
(
"ansible"
)
{
Void
addKeycloakUser
(
String
bezeichner
,
String
stage
,
String
bundesland
)
{
def
userFiles
=
sh
(
script:
'ls goofy-client/apps/goofy-e2e/src/fixtures/user'
,
returnStdout:
true
)
userFiles
.
split
(
"\\n"
).
each
{
user
->
...
...
@@ -570,7 +556,7 @@ Void addKeycloakUser(String bezeichner, String stage) {
def
ansibleVars
=
"""{"k8s_context":"ozg-dev", \
"kop_env":"dev", \
"keycloak_realm":"
sh
-${bezeichner}-dev", \
"keycloak_realm":"
${bundesland}
-${bezeichner}-dev", \
"user":${userJson}
}"""
...
...
@@ -584,10 +570,8 @@ Void addKeycloakUser(String bezeichner, String stage) {
}
}
}
}
Void
deleteKopStack
(
String
bezeichner
,
String
stage
)
{
container
(
"ansible"
)
{
dir
(
"${stage}/provisioning"
)
{
def
ansibleVars
=
"""{"k8s_context":"ozg-dev", \
"kop_env":"dev", \
...
...
@@ -601,7 +585,6 @@ Void deleteKopStack(String bezeichner, String stage) {
}
}
}
}
Void
publishE2ETestResult
(
String
reportFolder
,
String
reportName
)
{
publishHTML
(
...
...
@@ -616,10 +599,9 @@ Void publishE2ETestResult(String reportFolder, String reportName) {
)
}
String
runTests
(
String
stageName
,
String
bezeichner
,
String
reportFolder
)
{
def
configFile
=
generateCypressConfig
(
stageName
,
bezeichner
,
reportFolder
)
String
runTests
(
String
stageName
,
String
bezeichner
,
String
reportFolder
,
String
bundesland
,
dbPort
)
{
def
configFile
=
generateCypressConfig
(
stageName
,
bezeichner
,
reportFolder
,
bundesland
,
dbPort
)
container
(
"cypress"
)
{
try
{
dir
(
"goofy-client"
)
{
sh
"npm run cypress:version"
...
...
@@ -633,7 +615,6 @@ String runTests(String stageName, String bezeichner, String reportFolder) {
return
false
}
}
}
String
makeUrlConform
(
String
input
)
{
return
input
.
replaceAll
(
/[^a-zA-Z0-9]+/
,
""
).
toLowerCase
()
...
...
@@ -658,16 +639,18 @@ String cutBranchNameForKeycloakRealm(String branchName, String stageName) {
return
branchName
}
String
generateCypressConfig
(
String
stage
,
String
bezeichner
,
String
testFolder
)
{
def
namespace
=
"
sh
-${bezeichner}-dev"
String
generateCypressConfig
(
String
stage
,
String
bezeichner
,
String
testFolder
,
String
bundesland
,
dbPort
)
{
def
namespace
=
"
${bundesland}
-${bezeichner}-dev"
def
configName
=
"cypress-ci-"
+
testFolder
+
".json"
def
url
=
".dev.ozg-sh.de"
dir
(
'goofy-client/apps/goofy-e2e/'
){
def
config
=
readJSON
file:
'cypress-ci.json'
def
elasticsearchEnv
=
getElasticsearchEnv
(
namespace
)
config
.
baseUrl
=
"https://${bezeichner}.
dev.ozg-sh.de
"
as
String
config
.
env
.
dbUrl
=
"mongodb
+srv
://pluto-database-user:XnHhfznNWg65NNd@
pluto-database-svc.${namespace}.svc.cluster.local/admin?ssl=fals
e"
as
String
config
.
baseUrl
=
"https://${bezeichner}.
${url}
"
as
String
config
.
env
.
dbUrl
=
"mongodb://pluto-database-user:XnHhfznNWg65NNd@
localhost:${dbPort}/admin?ssl=false&directConnection=tru
e"
as
String
config
.
env
.
keycloakRealm
=
namespace
as
String
config
.
env
.
keycloakClient
=
namespace
+
"-goofy"
as
String
config
.
env
.
sabineUuid
=
getKeycloakUuid
(
namespace
,
"sabine"
)
as
String
...
...
@@ -679,7 +662,7 @@ String generateCypressConfig(String stage, String bezeichner, String testFolder)
environment
=
config
.
env
environment
.
put
(
"search"
,
elasticsearchEnv
)
environment
.
put
(
"userManager"
,
getUserManagerEnv
(
namespace
));
environment
.
put
(
"userManager"
,
getUserManagerEnv
(
namespace
,
dbPort
));
writeJSON
file:
configName
,
json:
config
...
...
@@ -689,21 +672,19 @@ String generateCypressConfig(String stage, String bezeichner, String testFolder)
return
configName
}
String
getUserManagerEnv
(
namespace
){
String
getUserManagerEnv
(
namespace
,
dbPort
){
def
secret
=
getSecrect
(
namespace
,
'pluto-database-admin-user-manager-database-user'
);
def
secretPassword
=
decodeString
(
secret
.
password
);
return
readJSON
(
text:
"""{
"dbUrl":"mongodb
+srv
://user-manager-database-user:${secretPassword}@
pluto-database-svc.${namespace}.svc.cluster.local/admin?ssl=fals
e", \
"dbUrl":"mongodb://user-manager-database-user:${secretPassword}@
localhost:${dbPort}/admin?ssl=false&directConnection=tru
e", \
"database":"user-manager-database"}"""
);
}
def
getSecrect
(
namespace
,
secretName
){
container
(
"k8s"
){
script
{
return
readJSON
(
text:
sh
(
script:
"kubectl get secret ${secretName} -n ${namespace} -o jsonpath={.data}"
,
returnStdout:
true
))
}
}
}
String
getKeycloakUuid
(
realm
,
userName
)
{
...
...
@@ -722,7 +703,7 @@ String getKeycloakUuid(realm, userName) {
}
String
getKeycloakAccessToken
()
{
withCredentials
([
usernamePassword
(
credentialsId:
'keycloak-
login
'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
withCredentials
([
usernamePassword
(
credentialsId:
'keycloak-
old-dev-cluster
'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
def
token
=
readJSON
text:
sh
(
script:
'curl -d "client_id=admin-cli" -d "username=$USER" -d "password=$PASSWORD" -d "grant_type=password" "https://sso.dev.ozg-sh.de/realms/master/protocol/openid-connect/token"'
,
returnStdout:
true
)
return
token
.
access_token
...
...
@@ -760,14 +741,12 @@ Void initHelmRepo() {
}
def
getElasticsearchSecret
(
namespace
)
{
container
(
"k8s"
){
script
{
def
elasticsearch
=
readJSON
(
text:
sh
(
script:
"kubectl get secret elasticsearch-credentials -n ${namespace} -o jsonpath={.data}"
,
returnStdout:
true
))
return
elasticsearch
}
}
}
String
getElasticsearchEnv
(
namespace
)
{
def
elasticsearchSecret
=
getElasticsearchSecret
(
namespace
)
...
...
@@ -776,7 +755,7 @@ String getElasticsearchEnv(namespace) {
"user":"${decodeString(elasticsearchSecret.username)}", \
"password":"${decodeString(elasticsearchSecret.password)}", \
"index":"${decodeString(elasticsearchSecret.index)}", \
"url":"
${decodeString(elasticsearchSecret.uris)}
"}"""
"url":"
http://localhost:9200
"}"""
return
readJSON
(
text:
env
)
}
...
...
@@ -817,3 +796,14 @@ Void pushNewProvisioningVersion(String environment) {
}
}
}
Void
exposeElasticSearch
()
{
portStatus
=
sh
(
script:
"lsof -i -P -n | grep LISTEN | grep :9200"
,
returnStatus:
true
)
as
Integer
if
(
portStatus
==
1
)
{
sh
"kubectl port-forward ozg-search-cluster-es-ozg-search-0 9200:9200 -n elastic-system &"
}
}
Void
exposeDatenbank
(
String
namespace
,
port
)
{
sh
"kubectl port-forward pluto-database-0 ${port}:27017 -n ${namespace} &"
}
\ No newline at end of file
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