84 lines
2.9 KiB
Groovy
84 lines
2.9 KiB
Groovy
def call(String projectName, Map config) {
|
|
pipeline {
|
|
agent {
|
|
kubernetes {
|
|
yaml k8sPodTemplate(config.namespace ?: 'default', config.useCustomDocker, config.pullAlways)
|
|
}
|
|
}
|
|
stages {
|
|
stage('Retrieve Environment Variables') {
|
|
steps {
|
|
script {
|
|
retrieveEnvVars('maven', ['NEXUS_URL', 'NEXUS_PASS'])
|
|
retrieveEnvVars('helm', ['KUBERNETES_API', 'KUBERNETES_TOKEN', 'NEXUS_URL'])
|
|
retrieveEnvVars(config.dockerTool ?: 'docker', ['NEXUS_DOCKER_URL', 'NEXUS_DOCKER_PASS'])
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Check dependent Pipeline Status') {
|
|
steps {
|
|
script {
|
|
if (config.checkDependencyPipeline) {
|
|
getJobStatus(config.dependencyPipeline)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('SonarQube Analysis') {
|
|
steps {
|
|
container('maven') {
|
|
withSonarQubeEnv('SonarQube') {
|
|
sh "mvn clean package sonar:sonar -Dsonar.projectKey=${projectName}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build and Deploy') {
|
|
steps {
|
|
withCredentials([
|
|
usernamePassword(credentialsId: 'quarkus-db-secret',
|
|
usernameVariable: 'USERNAME',
|
|
passwordVariable: 'PASSWORD')
|
|
]) {
|
|
|
|
script {
|
|
|
|
sh 'echo "DB User: $USERNAME"'
|
|
sh 'echo "DB Pass: $PASSWORD"'
|
|
|
|
def dbUser = USERNAME
|
|
def dbPass = PASSWORD
|
|
|
|
buildAndDeploy(
|
|
projectName,
|
|
config.helmChart,
|
|
config.helmRepo,
|
|
config.namespace,
|
|
config.version,
|
|
config.useCustomDocker,
|
|
config.useInsecureRegistry,
|
|
config.port,
|
|
dbUser,
|
|
dbPass
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
success {
|
|
echo "Build for '${projectName}' was successful!"
|
|
sh "curl -s -H 'Cache: no' -d '${projectName} -> Build Successful' https://ntfy.konsthol.eu/General"
|
|
}
|
|
failure {
|
|
echo "Build for '${projectName}' failed!"
|
|
sh "curl -s -H 'Cache: no' -d '${projectName} -> Build Failed' https://ntfy.konsthol.eu/General"
|
|
}
|
|
}
|
|
}
|
|
}
|