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
a81fe585
Commit
a81fe585
authored
3 years ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-1784 jenkinsfile
parent
11c8cd3d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Jenkinsfile
+27
-26
27 additions, 26 deletions
Jenkinsfile
with
27 additions
and
26 deletions
Jenkinsfile
+
27
−
26
View file @
a81fe585
...
...
@@ -61,7 +61,7 @@ pipeline {
parallel
(
startGoofy:
{
startGoofy
(
namespace
,
stageName
,
'ea-values.yaml'
)
startGoofy
(
namespace
,
'ea-values.yaml'
,
IMAGE_TAG
)
},
startPluto:
{
startPluto
(
namespace
,
'ea-values.yaml'
)
...
...
@@ -103,7 +103,7 @@ pipeline {
parallel
(
startGoofy:
{
startGoofy
(
namespace
,
stageName
,
'values.yaml'
)
startGoofy
(
namespace
,
'values.yaml'
,
IMAGE_TAG
)
},
startPluto:
{
startPluto
(
namespace
,
'values.yaml'
)
...
...
@@ -166,17 +166,17 @@ Void startPluto(String namespace, String values) {
}
}
Void
startGoofy
(
String
stageName
,
String
namespace
,
String
values
)
{
Void
startGoofy
(
String
namespace
,
String
values
,
String
imageTag
)
{
container
(
"k8s"
)
{
dir
(
'goofy-client/apps/goofy-e2e/deployment-values/goofy'
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
sh
"helm upgrade --install --create-namespace goofy goofy -f ${values} --set image.tag=${
IMAGE_TAG
} --namespace ${namespace}"
+
' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs'
sh
"helm upgrade --install --create-namespace goofy goofy -f ${values} --set image.tag=${
imageTag
} --namespace ${namespace}"
+
' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs'
}
}
createKeycloakGroups
(
stageNam
e
)
generateKeycloakUserYaml
(
stageNam
e
)
applyKeycloakUser
(
stageNam
e
)
createKeycloakGroups
(
namespac
e
)
generateKeycloakUserYaml
(
namespac
e
)
applyKeycloakUser
(
namespac
e
)
}
}
...
...
@@ -195,7 +195,7 @@ Void shutdownEnvironment(String namespace) {
sh
"helm uninstall goofy --namespace ${namespace} --wait"
sh
"helm uninstall pluto --namespace ${namespace} --wait"
removeKeycloakUser
(
stageNam
e
)
removeKeycloakUser
(
namespac
e
)
sh
"kubectl delete namespace ${namespace}"
}
...
...
@@ -212,8 +212,7 @@ String generateNamespaceName(String stage) {
return
"e2e-${branchName}${stageName}-dev"
}
Void
generateKeycloakUserYaml
(
String
stage
)
{
def
namespace
=
generateNamespaceName
(
stage
)
Void
generateKeycloakUserYaml
(
String
namespace
)
{
def
e2eUserFiles
=
sh
(
script:
'ls goofy-client/apps/goofy-e2e/src/fixtures/user'
,
returnStdout:
true
)
e2eUserFiles
.
split
(
"\\n"
).
each
{
user
->
...
...
@@ -252,7 +251,7 @@ Void createKeycloakGroups(String realm) {
def
groupFiles
=
sh
(
script:
'ls goofy-client/apps/goofy-e2e/src/fixtures/group'
,
returnStdout:
true
)
groupFiles
.
split
(
"\\n"
).
each
{
group
->
def
groupJson
=
readJSON
file:
'
goofy-client/apps/goofy-e2e/src/fixtures/group/
'
+
group
def
groupJson
=
sh
(
script:
"cat
goofy-client/apps/goofy-e2e/src/fixtures/group/
${
group
}"
,
returnStdout:
true
)
sh
"""curl -X POST 'https://sso.dev.ozg-sh.de/auth/admin/realms/${realm}/groups' \
-H 'Content-Type: application/json' \
...
...
@@ -262,8 +261,8 @@ Void createKeycloakGroups(String realm) {
}
}
Void
applyKeycloakUser
(
String
stag
e
)
{
dir
(
generateNamespaceName
(
stage
)
){
Void
applyKeycloakUser
(
String
namespac
e
)
{
dir
(
namespace
){
def
kcUserFiles
=
sh
(
script:
"ls"
,
returnStdout:
true
)
kcUserFiles
.
split
(
"\\n"
).
each
{
user
->
...
...
@@ -272,8 +271,8 @@ Void applyKeycloakUser(String stage) {
}
}
Void
removeKeycloakUser
(
String
stag
e
)
{
dir
(
generateNamespaceName
(
stage
)
){
Void
removeKeycloakUser
(
String
namespac
e
)
{
dir
(
namespace
){
def
kcUserFiles
=
sh
(
script:
"ls"
,
returnStdout:
true
)
kcUserFiles
.
split
(
"\\n"
).
each
{
user
->
...
...
@@ -293,7 +292,7 @@ String generateCypressConfig(String stage, String testFolder) {
config
.
env
.
dbUrl
=
"mongodb+srv://pluto-database-user:XnHhfznNWg65NNd@pluto-database-svc.${namespace}.svc.cluster.local/admin?ssl=false"
as
String
config
.
env
.
keycloakRealm
=
namespace
as
String
config
.
env
.
keycloakClient
=
namespace
+
"-goofy"
as
String
config
.
env
.
sabineUuid
=
getKeycloakUuid
(
namespace
,
'
sabine
'
)
as
String
config
.
env
.
sabineUuid
=
getKeycloakUuid
(
namespace
,
"
sabine
"
)
as
String
config
.
integrationFolder
=
"./src/integration/${testFolder}"
as
String
config
.
videosFolder
=
"./reports/${testFolder}/videos"
as
String
config
.
screenshotsFolder
=
"./reports/${testFolder}/screenshots"
as
String
...
...
@@ -306,22 +305,24 @@ String generateCypressConfig(String stage, String testFolder) {
}
String
getKeycloakUuid
(
realm
,
userName
)
{
def
users
=
sh
(
script:
"""curl -X POST 'https://sso.dev.ozg-sh.de/auth/admin/realms/${realm}/users' \
-H 'Content-Type: application/json' \
-H 'Authorization: bearer ${getKeycloakAccessToken()}'
"""
,
returnStdout:
true
)
users
.
each
{
user
->
def
shScript
=
"""curl -H 'Content-Type: application/json' \
-H 'Authorization: bearer ${getKeycloakAccessToken()}' \
'https://sso.dev.ozg-sh.de/auth/admin/realms/${realm}/users'
"""
def
users
=
readJSON
text:
sh
(
script:
shScript
,
returnStdout:
true
)
for
(
user
in
users
)
{
if
(
user
.
username
==
userName
)
{
return
user
.
id
return
user
.
id
}
}
}
String
getKeycloakAccessToken
()
{
withCredentials
([
usernamePassword
(
credentialsId:
'keycloak-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
def
token
=
sh
(
script:
'curl -d "client_id=admin-cli" -d "username=$USER" -d "password=$PASSWORD" -d "grant_type=password" "https://sso.dev.ozg-sh.de/auth/realms/master/protocol/openid-connect/token"'
,
returnStdout:
true
)
return
access_token
=
token
.
split
(
'"'
)[
3
]
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/auth/realms/master/protocol/openid-connect/token"'
,
returnStdout:
true
)
return
token
.
access_token
}
}
\ 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