Adjusting parameters
parent
2b12f710a0
commit
07cbe8e4c9
|
|
@ -6,8 +6,9 @@ pipeline {
|
||||||
agent {label 'libraryBuild'}
|
agent {label 'libraryBuild'}
|
||||||
parameters {
|
parameters {
|
||||||
string(name: 'CLUSTER', defaultValue: '', description: 'Enter the cluster name')
|
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: 'ENVIRONMENT', defaultValue: '', description: 'Enter single environment name. Possible values are: euprod, eupreprod, napreprod, naprod, cnprod. cnpreprod')
|
string(name: 'OWNER', defaultValue: '', description: 'Enter e-mail address of dashboard owner')
|
||||||
|
booleanParam(name: 'REMOVE', defaultValue: false, description: 'Check if dashboard for provided cluster should be removed instead of created')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,6 +46,7 @@ pipeline {
|
||||||
stage('Execute Dashboard script') {
|
stage('Execute Dashboard script') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
|
boolean remove = Boolean.getBoolean(REMOVE);
|
||||||
def SCRIPT_PARAMETER = ''
|
def SCRIPT_PARAMETER = ''
|
||||||
if(CLUSTER.isEmpty()) {
|
if(CLUSTER.isEmpty()) {
|
||||||
currentBuild.result = 'ABORTED'
|
currentBuild.result = 'ABORTED'
|
||||||
|
|
@ -56,9 +58,16 @@ pipeline {
|
||||||
error('Aborting due to missing ENVIRONMENT parameter')
|
error('Aborting due to missing ENVIRONMENT parameter')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
else if(OWNER.isEmpty()) {
|
||||||
|
currentBuild.result = 'ABORTED'
|
||||||
|
error('Aborting due to missing OWNER parameter')
|
||||||
|
return
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString()
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString()
|
||||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString()
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString()
|
||||||
|
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -O " + OWNER.toString()
|
||||||
|
if(remove) { SCRIPT_PARAMETER = SCRIPT_PARAMETER + " --remove "}
|
||||||
sh "python createDash.py ${SCRIPT_PARAMETER}"
|
sh "python createDash.py ${SCRIPT_PARAMETER}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ parser = argparse.ArgumentParser(description="Generate and deploy the Kubernetes
|
||||||
parser.add_argument("-C", "--cluster", type=str,required=True, help="Name of the Kubernetes cluster")
|
parser.add_argument("-C", "--cluster", type=str,required=True, help="Name of the Kubernetes cluster")
|
||||||
parser.add_argument('--remove', default=False, action='store_true', help="Remove dashboard for given cluster. If not specified dashboard will be created or updated")
|
parser.add_argument('--remove', default=False, action='store_true', help="Remove dashboard for given cluster. If not specified dashboard will be created or updated")
|
||||||
parser.add_argument('-E', '--environment', type=str, help="Name of the environment (the same as in environment.yaml file. Used to upload dashboard to specific Dynatrace environment. If not specified all environments in file will be used")
|
parser.add_argument('-E', '--environment', type=str, help="Name of the environment (the same as in environment.yaml file. Used to upload dashboard to specific Dynatrace environment. If not specified all environments in file will be used")
|
||||||
|
parser.add_argument('-O', '--owner', type=str, help="Email address of dashboard owner")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
def make_request(url, DTAPIToken,verify, method, jsondata):
|
def make_request(url, DTAPIToken,verify, method, jsondata):
|
||||||
headers = {
|
headers = {
|
||||||
|
|
@ -80,7 +80,7 @@ def create_or_update_dashboard(DTAPIToken, DTENV, dashboards, templatename, dash
|
||||||
newdashboard = {
|
newdashboard = {
|
||||||
"dashboardMetadata":{
|
"dashboardMetadata":{
|
||||||
"name": dashname,
|
"name": dashname,
|
||||||
"owner": config("DASHBOARD_OWNER"),
|
"owner": args.owner,
|
||||||
"tags": ["Kubernetes"],
|
"tags": ["Kubernetes"],
|
||||||
#"preset": 'true',
|
#"preset": 'true',
|
||||||
"shared":'true'
|
"shared":'true'
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ To provide authentication for API calls, create ".env" file in the script direct
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
usage: createDash.py [-h] -C CLUSTER [--remove] [-E ENVIRONMENT]
|
usage: createDash.py [-h] -C CLUSTER [--remove] [-E ENVIRONMENT] [-O OWNER]
|
||||||
|
|
||||||
Generate and deploy the Kubernetes Overview Dashboard as Code.
|
Generate and deploy the Kubernetes Overview Dashboard as Code.
|
||||||
|
|
||||||
|
|
@ -35,7 +35,10 @@ To provide authentication for API calls, create ".env" file in the script direct
|
||||||
Name of the Kubernetes cluster (default: None)
|
Name of the Kubernetes cluster (default: None)
|
||||||
--remove Remove dashboard for given cluster. If not specified dashboard will be created or updated (default: False)
|
--remove Remove dashboard for given cluster. If not specified dashboard will be created or updated (default: False)
|
||||||
-E ENVIRONMENT, --environment ENVIRONMENT
|
-E ENVIRONMENT, --environment ENVIRONMENT
|
||||||
Name of the environment (the same as in environment.yaml file. Used to upload dashboard to specific Dynatrace environment. If not specified all environments in file will be used (default: None)
|
Name of the environment (the same as in environment.yaml file. Used to upload dashboard to specific Dynatrace environment. If not specified all environments in file will be used
|
||||||
|
(default: None)
|
||||||
|
-O OWNER, --owner OWNER
|
||||||
|
Email address of dashboard owner (default: None)
|
||||||
# Files
|
# Files
|
||||||
|
|
||||||
## createDash.py
|
## createDash.py
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue