83 lines
3.4 KiB
Groovy
83 lines
3.4 KiB
Groovy
pipeline {
|
|
options {
|
|
ansiColor('xterm')
|
|
}
|
|
//label libraryBuild is available in CN JAWS and ROW JAWS, therefore this one was used; no additional intents
|
|
agent {label 'libraryBuild'}
|
|
parameters {
|
|
string(name: 'CLUSTER', defaultValue: '', description: 'Enter the cluster name')
|
|
choice(name: 'ENVIRONMENT', choices: ['euprod', 'eupreprod', 'napreprod', 'naprod', 'cnprod', 'cnpreprod'], description: 'Choose Dynatrace environment')
|
|
string(name: 'OWNER', defaultValue: '', description: 'Enter e-mail address of dashboard owner. Optional if REMOVE parameter is set to true')
|
|
booleanParam(name: 'REMOVE', defaultValue: false, description: 'Check if dashboard for provided cluster should be removed instead of created')
|
|
|
|
}
|
|
|
|
environment {
|
|
//ProxySettings
|
|
AUTH = credentials('proxy')
|
|
proxy_user = "${AUTH_USR}"
|
|
proxy_pw = "${AUTH_PSW}"
|
|
http_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
|
|
https_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
|
|
no_proxy="localhost,127.0.0.1,.muc,.bmwgroup.net"
|
|
HTTP_PROXY="${http_proxy}"
|
|
HTTPS_PROXY="${https_proxy}"
|
|
NO_PROXY="${no_proxy}"
|
|
|
|
EUPROD_TOKEN_VAR = credentials('EUPROD_TOKEN_VAR')
|
|
EUPREPROD_TOKEN_VAR = credentials('EUPREPROD_TOKEN_VAR')
|
|
NAPROD_TOKEN_VAR = credentials('NAPROD_TOKEN_VAR')
|
|
NAPREPROD_TOKEN_VAR = credentials('NAPREPROD_TOKEN_VAR')
|
|
CNPROD_TOKEN_VAR = credentials('CNPROD_TOKEN_VAR')
|
|
CNPREPROD_TOKEN_VAR = credentials('CNPREPROD_TOKEN_VAR')
|
|
|
|
}
|
|
|
|
stages {
|
|
stage('install required python packages') {
|
|
steps {
|
|
sh '''
|
|
pip install --user -r requirements.txt
|
|
'''
|
|
print env.JENKINS_URL
|
|
}
|
|
}
|
|
|
|
stage('Execute Dashboard script') {
|
|
steps {
|
|
script {
|
|
def SCRIPT_PARAMETER = ''
|
|
if(CLUSTER.isEmpty() || ENVIRONMENT.isEmpty()) {
|
|
currentBuild.result = 'ABORTED'
|
|
error('Aborting due to missing CLUSTER or ENVIRONMENT parameters')
|
|
return
|
|
}
|
|
else if(REMOVE.toBoolean()) {
|
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString()
|
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString()
|
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " --remove "
|
|
sh "python createDash.py ${SCRIPT_PARAMETER}"
|
|
}
|
|
else if(OWNER.isEmpty()) {
|
|
currentBuild.result = 'ABORTED'
|
|
error('Aborting due to missing OWNER parameter')
|
|
return
|
|
}
|
|
else {
|
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString()
|
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString()
|
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -O " + OWNER.toString()
|
|
sh "python createDash.py ${SCRIPT_PARAMETER}"
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
post {
|
|
always {
|
|
cleanWs()
|
|
}
|
|
}
|
|
} |