我在用管道处理Jenkinsfile时遇到了困难。
我有一个主Jenkins,它运行在一个码头容器和其他Jenkins奴隶,他们也是码头容器,有些是虚拟机(例如Windows 10)。
作为第一阶段和以后的阶段,我在母版中从Git执行代码签出。
艺名“Build”执行maven工件的生成。我使用一个坞映像来构建我的项目(基于Maven和Java9),不需要在主机和容器之间共享任何卷。我使用stash / unstash函数传递源代码,我还使用maven管道插件和选项withMaven(mavenLocalRepo: '')
我想在测试阶段将我在一个代理上构建的内容与其他代理共享,但在这一点上,存储库似乎不起作用(它说:“没有文件要存储”),而且我不能部署到中央maven存储库(我使用Nexus),因为有很多并发构建可能,部署也不安全。
我怎样才能解决这个问题?
管道实例:
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"){ ... }
}
}
}
}
}发布于 2017-11-10 15:24:59
我发现了问题:
如果您想从文件夹导入完整的内容,则应该使用路径(包括路径末尾的斜杠(/)符号)调用stash命令,否则它将被解释为文件,不会导入任何内容。
例如,
有效形式
stash includes: ".repository/", name "repository"无效表单(存储失败):
stash includes: ".repository", name "repository"https://stackoverflow.com/questions/47224781
复制相似问题