简体   繁体   English

Jenkins参数化构建不创建文件

[英]Jenkins parameterized build not creating file

Maybe I am misunderstanding the intended use for the Jenkins file parameter here...也许我在这里误解了 Jenkins 文件参数的预期用途......

I want to be able to upload a file containing some data (in my case comma separated variables).我希望能够上传一个包含一些数据的文件(在我的例子中是逗号分隔的变量)。 I then want to simply read this file and do stuff with the data.然后我想简单地读取这个文件并处理数据。 I've got this setup using a Pipeline job.我使用 Pipeline 作业进行了此设置。

My file location is set to 'email_list.csv'.我的文件位置设置为“email_list.csv”。 In my pipeline script I have在我的管道脚本中,我有

node {
  stage('post') {
    emailFile = readFile 'email_list.csv'
    println "${emailFile}"
    //.........
  }
}

This fails with a java.io.FileNotFoundException: /var/lib/jenkins/workspace/job-name/email_list.csv (No such file or directory) exception这失败并出现java.io.FileNotFoundException: /var/lib/jenkins/workspace/job-name/email_list.csv (No such file or directory)异常

Shouldn't the parameterized build have set up this file?参数化构建不应该设置这个文件吗? If not, how do I read the data uploaded?如果没有,我如何读取上传的数据?

Jenkins by default provides build job parameters as a params map in pipeline. Jenkins 默认提供构建作业参数作为管道中的params映射。 It is a key-value pair.它是一个键值对。 All you comma seperated values will be into values field.所有逗号分隔的值都将进入值字段。 You can refer them in your groovy script as,你可以在你的 groovy 脚本中引用它们,

print params.emailFile

To dump it as a file, you can use writeFile library function.要将其转储为文件,您可以使用writeFile库函数。

PS: If you print params in groovy script, you will be able to see all build parameters of your job. PS:如果您在 groovy 脚本中print params ,您将能够看到您作业的所有构建参数。

There is aa bug since ages that makes impossible to use fileParameter :有一个自古以来就无法使用fileParameter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM