简体   繁体   中英

stash/unstash to transfer data from a build container to other node ( in jenkins)

in my CI infrastrucure i have a jenkins master running as a container and 2 slaves (vms) . i try to run a build inside a docker container on a node so during the build process i was stashed my target folder to use it later on other node . in the job's log i can see that the folder stashed succefully. when the build was finished the container is automatically destroyed then in the next step i unstash that folder to acheive another stages in separate node but nothings happened.. seems like unstash didn't anything.

plz how can i transfer my target from the container to another node or even to the master???

this my pipeline code :

 node('docker') { stage('Checkout Code') { checkout scm } stage('Build') { withMaven( jdk: 'jdk_8', maven: 'maven 3') { mvn 'clean install' stash name: 'war', includes: 'x.war' } } node('master') { stage('test') { withMaven( jdk: 'jdk_8', maven: 'maven 3') { unstash : 'war' sh 'mvn clean test' } } } } 

I doubt that the war is actually being stashed since the generated war should not be in the same directory where you executed mvn clean install .

I expect the war to be under target. You may want to change includes: 'x.war' to includes: 'target/x.war' . Alternatively, go to the maven repository where the war is installed and stash the file from there:

withMaven( jdk: 'jdk_8', maven: 'maven 3') {
  mvn 'clean install'
  dir('<path to war>'){
      stash name: 'war', includes: 'x.war'
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM