Skip to content

Commit c391629

Browse files
authored
Update Jenkinsfile
1 parent 10a18e2 commit c391629

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Jenkinsfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
pipeline {
2-
agent none // no global agent; define per stage
2+
agent none
33

44
stages {
5-
5+
66
stage('Build') {
7-
tools{maven 'MAVEN'}
8-
agent {label 'built-in'}
7+
agent { label 'built-in' }
8+
tools { maven 'MAVEN' }
99
steps {
10-
// Skip tests during build
1110
bat 'mvn clean install -DskipTests'
11+
archiveArtifacts artifacts: 'target/my-app-1.0-SNAPSHOT.jar', fingerprint: true
1212
}
13-
steps {
13+
}
14+
15+
stage('Test') {
16+
agent { label 'built-in' }
17+
tools { maven 'MAVEN' }
18+
steps {
1419
bat 'mvn test'
1520
}
1621
}
1722

1823
stage('Run on Slave') {
19-
agent { label 'docker' } // your slave node label
24+
agent { label 'docker' }
2025
steps {
21-
sh 'java -jar target/my-app-1.0-SNAPSHOT.jar'
26+
// Copy JAR from master to slave
27+
copyArtifacts(
28+
projectName: env.JOB_NAME,
29+
selector: lastSuccessful(),
30+
filter: 'target/my-app-1.0-SNAPSHOT.jar'
31+
)
32+
sh 'java -jar my-app-1.0-SNAPSHOT.jar'
2233
}
2334
}
2435
}

0 commit comments

Comments
 (0)