首页 文章

使用Jenkins管道在节点之间复制构建工件

提问于
浏览
13

我正在尝试将现有的Jenkins构建作业移动到单个Jenkins 2管道,并想知道是否可以在构建中将文件从一个节点复制到另一个节点 . 我的想法是:

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,但使用完全独立的构建作业) .

1 回答

  • 12

    是的,这可以使用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"                                                       
                           } 
                       }
              )
    

相关问题