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

Merge pull request 'OZG-6537: Restore pvog build. Refactor deployToNexus....

Merge pull request 'OZG-6537: Restore pvog build. Refactor deployToNexus. Refactor deployHelmChart.' (#81) from OZG-6537-fix-pvog-build into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/zufi-manager/pulls/81


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 66b1d606 f7fae903
No related branches found
No related tags found
No related merge requests found
......@@ -113,21 +113,17 @@ pipeline {
script {
FAILED_STAGE = env.STAGE_NAME
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh '''
mvn -pl zufi-manager-server \
-s $MAVEN_SETTINGS spring-boot:build-image \
-DskipTests \
-Dmaven.wagon.http.retryHandler.count=3 \
$BUILD_PROFILE \
-Ddocker.publishRegistry.username=${USER} \
-Ddocker.publishRegistry.password=${PASSWORD} \
-DimageTag=$IMAGE_TAG \
-DpublishImage=true
'''
buildAndPushImage("zufi-manager-server")
}
}
}
stage('Build, Tag and Push zufi-manager-pvog Docker image') {
steps {
script {
FAILED_STAGE = env.STAGE_NAME
buildAndPushImage("zufi-manager-pvog")
}
}
}
......@@ -161,23 +157,6 @@ pipeline {
}
}
stage ('OWASP Dependency-Check Vulnerabilities') {
steps {
dependencyCheck additionalArguments: '''
-o "./"
-s "./"
-f "ALL"
-d /dependency-check-data
--suppression dependency-check-supressions.xml
--disableKnownExploited
--noupdate
--disableArchive
--prettyPrint''', odcInstallation: 'dependency-check-owasp'
dependencyCheckPublisher pattern: 'dependency-check-report.xml'
}
}
stage('Sonar Checks') {
when {
branch 'master'
......@@ -271,18 +250,32 @@ pipeline {
}
}
Void buildAndPushImage(String applicationName){
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh script: """
mvn -pl ${applicationName} \
-s \$MAVEN_SETTINGS spring-boot:build-image \
-DskipTests \
-Dmaven.wagon.http.retryHandler.count=3 \
\$BUILD_PROFILE \
-Ddocker.publishRegistry.username=\$USER \
-Ddocker.publishRegistry.password=\$PASSWORD \
-DimageTag=\$IMAGE_TAG \
-DpublishImage=true
"""
}
}
}
Void deployHelmChart(String helmChartName, String helmChartVersion) {
def helmChartArchive = "${helmChartName}-${helmChartVersion}.tgz"
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=@''' + "${helmChartName}-${helmChartVersion}.tgz", returnStdout: true
result = deployChartToNexus('$USERNAME:$PASSWORD', helmChartArchive, "ozg-base-apps")
} else {
result = sh script: '''
curl -u $USERNAME:$PASSWORD \
https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot \
-F file=@''' + "${helmChartName}-${helmChartVersion}.tgz", returnStdout: true
result = deployChartToNexus('$USERNAME:$PASSWORD', helmChartArchive, "ozg-base-apps-snapshot")
}
if (result != '') {
......@@ -291,6 +284,14 @@ Void deployHelmChart(String helmChartName, String helmChartVersion) {
}
}
String deployChartToNexus(String usernamePassword, String helmChartArchive, String repository) {
return sh(script: """
curl -u "${usernamePassword}" \
"https://nexus.ozg-sh.de/service/rest/v1/components?repository=${repository}" \
-F file=@${helmChartArchive}
""", returnStdout: true).trim()
}
String generateHelmChartVersion() {
def chartVersion = getRootPomVersion()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment