How to share local Maven repo between nodes?

51 views
Skip to first unread message

Torsten Reinhard

unread,
Oct 23, 2017, 4:44:37 PM10/23/17
to Jenkins Users
Hi,

I have a large build & deploy pipeline with some stages, running on different nodes. I´m using stash/unstash for transfering the files (sources) between the nodes
- but how do I share the artifacts of the local M2 repository so dependencies can be resolved properly?

node(..) {
 
..
  stage
("Build") {
   
// build it
    sh
("mvn clean install....")
 
}
 
..
  stash ( name: 'workspace', useDefaultExcludes: false, excludes: "**/target/**/*.class, **/target/surefire-reports/**")

}

node
(..) {
  ..
  stage
("Deploy") {
     sh
("deploy.sh.....")
 
}
 
..
}

node(..) {
  unstash( name: 'workspace')
  stage("Test") {
    ..
    sh("mvn test -Pit..")
    ..
  }
}

Is there a way (without declarative pipeline) to "reuse" the same node like before? Or do I have to stash/unstash the local repo or parts of it, too?

Any other ideas ?

Thanx for your responses,

Torsten

Robert Hales

unread,
Oct 23, 2017, 4:54:06 PM10/23/17
to Jenkins Users
You can caputre the node name in the first time you use the node and then specify it as the node label in the following node steps. 

Torsten Reinhard

unread,
Oct 25, 2017, 6:29:26 AM10/25/17
to Jenkins Users
Thanx, now I´m doing something like:
String buildNode
node
() {
    buildNode
= env.NODE_NAME
    echo
"performing build on node ${buildNode}"
}
checkpoint
("built")
node
('other') {
    echo
"running on any other node, currently it´s ${env.NODE_NAME}"
}
checkpoint
("deployed")
node
( buildNode ) {
    echo "running on ${buildNode} again - it´s ${env.NODE_NAME}"
}
Reply all
Reply to author
Forward
0 new messages