2016-06-07 84 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"              
         } 
        } 
     ) 
相關問題