2016-06-07 105 views
9

我试图将现有的Jenkins构建工作移动到单个Jenkins 2管道,并且想知道是否可以在构建内将文件从一个节点复制到另一个节点。我的想法是:使用Jenkins管道在节点之间复制构建工件

Node A (Windows) 
    Checkout scm 
    Execute ant build 
    Archive artifact (or whatever required action) 
Node B (Unix) 
    Checkout scm 
    Copy build artifact from node A --> is this possible ? 
    Execute ant build 
    Then followed by tests... 

我试图使用复制神器的一步,但它似乎没有正常工作,所以我不知道是否有在的中间复制文件的方式管道,或者如果我必须留在当前的构建体系结构(使用copy artifact plugin,但完全独立的构建作业)。

+0

欢迎计算器。您可以在您的帖子中添加“似乎无法正常工作”的代码... ;-) – StephenKing

+0

我正在使用'step([$ class:'ArtifactArchiver',artifacts:'dist/*。zip']] )'将工件归档到第一个节点上,然后'step([$ class:'CopyArtifact',filter:'dist/*。zip',fingerprintArtifacts:true,projectName:'PCT')'但是工件似乎只是在构建结束后可用 –

回答

7

是的,这可以使用stash/unstash步骤。

有关此的指南也可以在Jenkins Blog(集中于并行执行)实测值:

parallel (
    "stream 1" : { 
        node { 
          unstash "binary"       
          sh "sleep 20s" 
          sh "echo hstream1" 
         } 
        }, 
    "stream 2" : { 
        node { 
          unstash "binary" 
          sh "echo hello2" 
          sh "hashtag fail"              
         } 
        } 
     ) 
相关问题