I'm having hard problems with a Jenkinsfile with a Pipeline.
I have a master Jenkins which runs in a docker container and other Jenkins slaves, which are also docker containers and some are Virtual Machines (e.g., Windows 10).
I perform the code checkout from Git in the master as first stage and for the further stages.
A Stage name 'Build' performs the generation of maven artifacts. I use one docker image to build my project (based on Maven and Java 9) without sharing any volume across host and container. I pass the source code using the stash
/ unstash
functions.I'm using also the maven-pipeline plugin and the option withMaven(mavenLocalRepo: '')
I'd like to share what I've built on one agent to other agents in a Test stage, but it looks like at this point, stashing of repository is not working (it says: 'no file to stash') and I cannot deploy to a central maven repository (I use Nexus), because there are many concurrent builds possible and the deploy could not be safe.
How can I solve this issue?
Example of pipeline:
pipeline{
agent none
stages{
stage('Checkout Repository'){
agent { node { label 'master' } }
steps{
checkout scm
stash includes: 'project/', name 'project'
}
}
stage('Build'){
agent { node { label 'docker-app-builder' } }
steps{
unstash "project"
withMaven(mavenLocalRepo: ".repository"){ sh 'mvn clean install' }
stash includes: ".repository", name "repository"
}
}
}
stage("Test){
steps{
parallel "docker slave": {
node("docker-app-tester"){
unstash "repository"
unstash "project"
withMaven(mavenLocalRepo: ".repository"){ ... }
}
},
"Windows Slave": {
node("windows-tester"){
unstash "repository"
unstash "project"
withMaven(mavenLocalRepo: ".repository"){ ... }
}
}
}
}
}
and I cannot deploy to a central maven repository (I use Nexus), because there are many concurrent builds possible and the deploy could not be safe....
Why can't you deploy to your nexus? What is the problem here? – khmarbaise