forked from devops-ws/learn-pipeline-java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile.jmeter.groovy
52 lines (47 loc) · 2.16 KB
/
Jenkinsfile.jmeter.groovy
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
// this case requires docker image egaillardon/jmeter
// you should run this pipeline under the kubernetes, and a container named jmeter is required
// In order to execute this successfuly, please install plugins using below command
// jcli plugin install kubernetes htmlpublisher pipeline-restful-api
pipeline{
agent{
label 'jmeter'
}
stages{
stage('test'){
steps{
script{
container('jmeter'){
sh 'rm -rf result && rm -rf result.jtl && jmeter -n -t src/test/resources/baidu-jmeter.jmx -l result.jtl -e -o result'
// below is an example for sending test report to a generic artifact server
// see more details from https://github.com/mayth/go-simple-upload-server/pull/14
// sh 'curl http://10.0.129.98:12345'
// def files = findFiles glob: 'result/**/*'
// for(file in files) {
// def path = file.path.replaceAll('result/', '').replaceAll(file.name, '')
// path = currentBuild.fullProjectName + '/' + currentBuild.number + '/' + path
// sh 'curl -Ffile=@' + file.path + ' "http://10.0.129.98:12345/upload?token=testtoken&path=' + path + '"'
// }
// echo 'http://10.0.129.98:12345/' + currentBuild.fullProjectName + '/' + currentBuild.number + '/index.html'
}
}
}
}
stage('report'){
steps{
script{
container('jmeter'){
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'result', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: ''])
}
}
}
}
stage('artifacts') {
steps {
container('jmeter') {
sh 'tar czf result.tar.gz result'
archiveArtifacts 'result.tar.gz'
}
}
}
}
}