File tree Expand file tree Collapse file tree 1 file changed +32
-18
lines changed
Expand file tree Collapse file tree 1 file changed +32
-18
lines changed Original file line number Diff line number Diff line change 1- stage(" Build" ) {
2- agent { label ' built-in' } // Windows master
3- steps {
4- bat " mvn clean package"
5- stash includes : ' target/*.jar' , name : ' myAppJar'
1+ pipeline {
2+ agent none // assign agents per stage
3+ tools {
4+ maven " MAVEN" // name of Maven installation in Jenkins
65 }
7- }
8-
9- stage(" Run on Slaves" ) {
10- parallel {
11- stage(" Run on Slave1" ) {
12- agent { label ' slave1' }
6+ stages {
7+ stage(" Build on Master" ) {
8+ agent { label ' built-in' } // Built-in Windows master
139 steps {
14- unstash ' myAppJar '
15- sh " java -cp target/my-app-1.0-SNAPSHOT. jar com.mycompany.app.App "
10+ bat " mvn clean package "
11+ stash includes : ' target/*. jar' , name : ' myAppJar '
1612 }
1713 }
18- stage(" Run on Slave2" ) {
19- agent { label ' slave2' }
20- steps {
21- unstash ' myAppJar'
22- sh " java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App"
14+
15+ stage(" Run on Slaves" ) {
16+ parallel {
17+ stage(" Run on Server1" ) {
18+ agent { label ' server1' } // Linux slave1
19+ steps {
20+ unstash ' myAppJar'
21+ sh " java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App"
22+ }
23+ }
24+ stage(" Run on Server2" ) {
25+ agent { label ' server2' } // Linux slave2
26+ steps {
27+ unstash ' myAppJar'
28+ sh " java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App"
29+ }
30+ }
2331 }
2432 }
2533 }
34+
35+ post {
36+ success {
37+ archiveArtifacts artifacts : " target/*.jar"
38+ }
39+ }
2640}
You can’t perform that action at this time.
0 commit comments