MDalt
MDalt

Reputation: 1801

Jenkins parameterized build not creating file

Maybe I am misunderstanding the intended use for the Jenkins file parameter here...

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.

My file location is set to '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

Shouldn't the parameterized build have set up this file? If not, how do I read the data uploaded?

Upvotes: 4

Views: 1505

Answers (2)

sai
sai

Reputation: 450

Jenkins by default provides build job parameters as a params map in pipeline. 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,

print params.emailFile

To dump it as a file, you can use writeFile library function.

P.S: If you print params in groovy script, you will be able to see all build parameters of your job.

Upvotes: 1

GalloCedrone
GalloCedrone

Reputation: 5073

There is a a bug since ages that makes impossible to use fileParameter:

Upvotes: 0

Related Questions