栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Jenkins管道,如何将工件从以前的版本复制到当前版本?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Jenkins管道,如何将工件从以前的版本复制到当前版本?

Stuart Rowe还在管道制作Sig
Gitter频道
上向我推荐了我查看“复制工件插件”的方法,但也给了我一些要使用的Jenkins
Pipeline语法
示例。

根据他给出的建议,我想到了一个更完整的Pipeline示例,该示例将工件从先前的构建复制到当前的构建中,而不管先前的构建是成功还是失败。

pipeline {    agent any;    stages {        stage("Zeroth stage") { steps {     script {         if (currentBuild.previousBuild) {  try {      copyArtifacts(projectName: currentBuild.projectName,         selector: specific("${currentBuild.previousBuild.number}"))      def previousFile = readFile(file: "usefulfile.txt")      echo("The current build is ${currentBuild.number}")      echo("The previous build artifact was: ${previousFile}")  } catch(err) {      // ignore error  }         }     } }        }        stage("First stage") { steps {     echo("Hello")     writeFile(file: "usefulfile.txt", text: "This file ${env.BUILD_NUMBER} is useful, need to archive it.")     archiveArtifacts(artifacts: 'usefulfile.txt') }        }        stage("Error") { steps {     error("Failed") }        }    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/401596.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号