File tree Expand file tree Collapse file tree 1 file changed +33
-16
lines changed
Expand file tree Collapse file tree 1 file changed +33
-16
lines changed Original file line number Diff line number Diff line change 11pipeline {
2- agent none
2+ agent none // No global agent, define per stage
33
44 stages {
5- stage(' Build' ) {
6- agent { label ' built-in' }
7- tools { maven ' MAVEN' }
8- steps {
9- bat ' mvn clean install -DskipTests'
10- stash includes : ' target/my-app-1.0-SNAPSHOT.jar' , name : ' app-jar'
11- }
12- }
135
14- stage(' Run on Slave' ) {
15- agent { label ' docker' }
16- steps {
17- unstash ' app-jar'
18- sh ' java -jar my-app-1.0-SNAPSHOT.jar'
19- }
20- }
6+ stage(' Build' ) {
7+ agent { label ' built-in' } // Master node (Windows)
8+ tools { maven ' MAVEN' }
9+ steps {
10+ // Clean build, skip tests
11+ bat ' mvn clean install -DskipTests'
12+
13+ // Stash the JAR for slave
14+ stash includes : ' target/my-app-1.0-SNAPSHOT.jar' , name : ' app-jar' , useDefaultExcludes : false
15+ }
16+ }
17+
18+ stage(' Test' ) {
19+ agent { label ' built-in' } // Master node (Windows)
20+ tools { maven ' MAVEN' }
21+ steps {
22+ bat ' mvn test'
23+ }
24+ }
25+
26+ stage(' Run on Slave' ) {
27+ agent { label ' docker' } // Slave node label
28+ steps {
29+ // Clean workspace on slave before unstashing
30+ sh ' rm -rf *'
31+
32+ // Retrieve the JAR
33+ unstash ' app-jar'
2134
35+ // Run the JAR
36+ sh ' java -jar target/my-app-1.0-SNAPSHOT.jar'
37+ }
38+ }
2239 }
2340}
You can’t perform that action at this time.
0 commit comments