如何将文件参数传递给jenkins管道中的另一个构建作业?
如何将当前工作区中的文件作为参数传递给生成作业,例如:如何将文件参数传递给jenkins管道中的另一个构建作业?,jenkins,jenkins-pipeline,jenkins-2,Jenkins,Jenkins Pipeline,Jenkins 2,如何将当前工作区中的文件作为参数传递给生成作业,例如: build job: 'other-project', parameters: [[$class: 'FileParameterValue', ????]] 您可以传递文件的完整路径,您可以执行以下操作: node('master') { //Read the workspace path String path = pwd(); String pathFile = "${path}/exampleDir/fileExampl
build job: 'other-project', parameters: [[$class: 'FileParameterValue', ????]]
您可以传递文件的完整路径,您可以执行以下操作:
node('master') {
//Read the workspace path
String path = pwd();
String pathFile = "${path}/exampleDir/fileExample.ext";
//Do whatever you wish with the file path
}
真是一场噩梦——没有文档,没有查看詹金斯代码等等。。什么都试过了 最终发现这目前不起作用。这是詹金斯虫子 从这里链接到: 您需要传入一个FileParameterValue
此方法假定您在当前作业的工作区中拥有该文件
pipeline
{
agent any
stages {
stage('Pass file type param to build job') {
steps {
script {
def propertiesFilePath = "${env.WORKSPACE}/sample.properties"
build job: 'other-project',
parameters: [[$class: "FileParameterValue", name: "propertiesFile", file: new FileParameterValue.FileItemImpl(new File(propertiesFilePath))]]
}
}
}
}
}
此处,下游/子作业的名称为“其他项目”,此下游/子作业中的文件类型参数的名称为“propertiesFile”。
该类型在类中定义,并在jenkins中内部用于处理FileItem,还向该类添加了序列化支持