Files
my-jenkins-library/vars/jenkinsPipelineSkeleton.groovy

59 lines
2.1 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 {
script {
buildAndDeploy(projectName, config.helmChart, config.helmRepo, config.namespace, config.version, config.useCustomDocker, config.useInsecureRegistry, config.port)
}
}
}
}
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"
}
}
}
}