-
Notifications
You must be signed in to change notification settings - Fork 9
/
keptnperftesting.Jenkinsfile
59 lines (53 loc) · 4.26 KB
/
keptnperftesting.Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@Library('[email protected]')_
def keptn = new sh.keptn.Keptn()
node {
properties([
parameters([
string(defaultValue: 'perfaasproject', description: 'Name of your Keptn Project for Performance as a Self-Service', name: 'Project', trim: false),
string(defaultValue: 'performance', description: 'Stage in your Keptn project used for Performance Feedback', name: 'Stage', trim: false),
string(defaultValue: 'perfaasservice', description: 'Servicename used to keep SLIs, SLOs, test files ...', name: 'Service', trim: false),
choice(choices: ['dynatrace', 'prometheus',''], description: 'Select which monitoring tool should be configured as SLI provider', name: 'Monitoring', trim: false),
choice(choices: ['performance', 'performance_10', 'performance_50', 'performance_100', 'performance_long'], description: 'Test Strategy aka Workload, e.g: performance, performance_10, performance_50, performance_100, performance_long', name: 'TestStrategy', trim: false),
choice(choices: ['perftest','basic'], description: 'Decide which set of SLIs you want to evaluate. The sample comes with: basic and perftest', name: 'SLI'),
string(defaultValue: 'http://simplenode.simpleproject-staging.keptn06-agrabner.demo.keptn.sh', description: 'URI of the application you want to run a test against', name: 'DeploymentURI', trim: false),
string(defaultValue: '60', description: 'How many minutes to wait until Keptn is done? 0 to not wait', name: 'WaitForResult'),
])
])
stage('Initialize Keptn') {
// keptn.downloadFile('https://raw.githubusercontent.com/keptn-sandbox/performance-testing-as-selfservice-tutorial/master/shipyard.yaml', 'keptn/shipyard.yaml')
keptn.downloadFile("https://raw.githubusercontent.com/keptn-sandbox/jenkins-tutorial/master/usecases/uc1_qualitygates/keptn/dynatrace/dynatrace.conf.yaml", 'keptn/dynatrace/dynatrace.conf.yaml')
keptn.downloadFile("https://raw.githubusercontent.com/keptn-sandbox/jenkins-tutorial/master/usecases/uc1_qualitygates/keptn/slo_${params.SLI}.yaml", 'keptn/slo.yaml')
keptn.downloadFile("https://raw.githubusercontent.com/keptn-sandbox/jenkins-tutorial/master/usecases/uc1_qualitygates/keptn/dynatrace/sli_${params.SLI}.yaml", 'keptn/sli.yaml')
keptn.downloadFile('https://raw.githubusercontent.com/keptn-sandbox/jenkins-tutorial/master/usecases/uc1_qualitygates/keptn/jmeter/load.jmx', 'keptn/jmeter/load.jmx')
keptn.downloadFile('https://raw.githubusercontent.com/keptn-sandbox/jenkins-tutorial/master/usecases/uc1_qualitygates/keptn/jmeter/jmeter.conf.yaml', 'keptn/jmeter/jmeter.conf.yaml')
archiveArtifacts artifacts:'keptn/**/*.*'
// Initialize the Keptn Project
keptn.keptnInit project:"${params.Project}", service:"${params.Service}", stage:"${params.Stage}", monitoring:"${monitoring}" // , shipyard:'shipyard.yaml'
// Upload all the files
keptn.keptnAddResources('keptn/dynatrace/dynatrace.conf.yaml','dynatrace/dynatrace.conf.yaml')
keptn.keptnAddResources('keptn/sli.yaml','dynatrace/sli.yaml')
keptn.keptnAddResources('keptn/slo.yaml','slo.yaml')
keptn.keptnAddResources('keptn/jmeter/load.jmx','jmeter/load.jmx')
keptn.keptnAddResources('keptn/jmeter/jmeter.conf.yaml','jmeter/jmeter.conf.yaml')
}
stage('Trigger Performance Test') {
echo "Performance as a Self-Service: Triggering Keptn to execute Tests against ${params.DeploymentURI}"
// send deployment finished to trigger tests
def keptnContext = keptn.sendDeploymentFinishedEvent testStrategy:"${params.TestStrategy}", deploymentURI:"${params.DeploymentURI}"
String keptn_bridge = env.KEPTN_BRIDGE
echo "Open Keptns Bridge: ${keptn_bridge}/trace/${keptnContext}"
}
stage('Wait for Result') {
waitTime = 0
if(params.WaitForResult?.isInteger()) {
waitTime = params.WaitForResult.toInteger()
}
if(waitTime > 0) {
echo "Waiting until Keptn is done and returns the results"
def result = keptn.waitForEvaluationDoneEvent setBuildResult:true, waitTime:waitTime
echo "${result}"
} else {
echo "Not waiting for results. Please check the Keptns bridge for the details!"
}
}
}