86892

Send array of object inside custom Azure DevOps tasks / extensions

<h3>Question</h3>

I want to create a custom Task for Azure DevOps and I would like to have an array of object as parameters and use it like this in yaml:

data: - field1: "data1" field2: "data2" - field1: "data3" field2: "data4"

However I didn't found any avalable methods or examples for this kind of case, only simple array like string array. How an I pass a listof object from yaml to my custom Azure DevOps task? Feel free to ask me some more details if needed.

EDIT:

For example, I want to send a complexe lisf of object:

data: # Data should be an array - object: file1: "/myDestinationPath" file2: "/TheFilePathToSend" override: true - object: file1: "/myDestinationPath2" file2: "/TheFilePathToSend2" override: false ...

Then I expect to load it, something like:

let dataArray = task.getPathInput('data', true);

Where dataArray can ba a simple JSON array, it will be easy to manage after.


<h3>Answer1:</h3>

Fandro, a suggestion could be changing the way you organize your parameters and use taskgetDelimitedInput function.

Assuming you are using Azure pipeline task lib in TypeScript and familiarity with Build task creation.

Step 1) Define your variables using delimiter (e.g. | ) inside the task.json file.

dataOrigin: "/myDestinationPath|/myDestinationPath2" dataDestination: "/TheFilePathToSend|/TheFilePathToSend2" dataOverwriteCriteria: "true|false"

Step 2) Edit your task file (e.g. index.ts ) you may use taskgetDelimitedInput, it returns the string array.

Step 3) Manipulate your values:

let dataOriginArray = task.taskgetDelimitedInput('dataOrigin', "|"); let dataDestinationArray = task.taskgetDelimitedInput('dataDestination', "|"); let dataOverwriteCriteriaArray = task.taskgetDelimitedInput('dataOverwriteCriteria', "|");

来源:https://stackoverflow.com/questions/60993631/send-array-of-object-inside-custom-azure-devops-tasks-extensions

Recommend

  • Send array of object inside custom Azure DevOps tasks / extensions
  • Using Facebook Graph API 2.2 to get like and share count
  • Reference from UITableViewCell to UITableView to UINavigationController
  • Firebase tracking/limiting of user request volume
  • Rails traverse deep array of hashes
  • AngularJS User Login to Json file
  • Parallel exact matrix diagonalization with Python
  • How to scroll the horizontal scrollbar in an iFrame from the parent frame?
  • Eloquent Javascript: Can't understand how the number value is determined in the sum function
  • copy smaller array into larger array
  • How to detect beginning of line, or: “The name 'getCharPositionInLine' does not exist in t
  • Is there a way to convert all existing table data to UTF8 collation?
  • How to get the available translations from a dll
  • Fixing corrupt encoding (with Python)
  • ODBC connection to an .accdb file
  • How to concatenate data.frame inside lists by using names?
  • iterating through image folder using javascript and adding the result in HTML
  • Forward slash vs backward slash for file path in git bash
  • device tree overlay phandle
  • Create One-To-One relationship between table and view in EF4?
  • Move elements from a listbox to another
  • Google Compute instance receiving email
  • Problems with special characters in php soap client
  • C# ICMPv6 checksum calculation
  • Using loops in Jasmine (with injected service)
  • Excel Reverse Match
  • Is possible having two COM STA instances of the same component?
  • Unable to run testNG tests from maven
  • Shiny - change the size (padding?) of dropdown menu (select tags) smaller
  • AWS RDS Parameter Group not changing MySQL encoding
  • Controller or RestController
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SpringDispatcher-ser
  • Tensorflow Dataset API restore Iterator after completing one epoch
  • Google Spreadsheet Script to Blink a range of Cells
  • how to get the location(lat/lng) on google maps v3 from the location(x,y)
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • Capture SIGFPE from SIMD instruction