Upload File as a parameter to job in Azure DevOps

Viewed 2245

I have a Azure DevOps pipeline that automates user creation in salesforce. I am expecting the user details in an excel file, which is to be fed to the Azure DevOps pipeline as a pre-build parameter. However, I am not able to find a solution to it in Azure DevOps.

I had implemented this in Jenkins already using File parameter plugin in my previous projects. Does Azure DevOps has this capability?

3 Answers

After searching through various blogs and posts, I realized that there is no way to get this done directly in VSTS. However, I was able to get a work around for the same.

  1. I created a VSTS User story and uploaded my attachment there
  2. Using the Work Item ID, I used the work Item api to get the attachment ID.
  3. Using the attachment API I was able to write a python script to download this attachment as a part of a pre-step in the Pipeline. Then this was available to use through out my automation script.

I don't think you can load a file before the build start and read the variables, but, you can add a task that read the variables from a file and put him in the beginning (the first step in your pipeline).

There are few extensions to read variable from a JSON file, for example: Json to Variable.

If you want to read from excel I think you should write a script that does it.

Related