Forum Discussion
Azurepipeline Extension- doesn't give any error nor able to show dynamic dropdown value
I have created an extension, pushed to Marketplace & then used it in my org all this went so smooth. then when I started building Pipe line at TASK step when I choose my extension it is populating a field that has options pre-defined. but when it comes to dynamic it says "Not Found" aka empty.
Details:-
Custom step has 3 fields.
- Category- Cars [ pre defined option list ]
- Color - Blue [ pre defined option list ]
- Car List - this used endpoint - https://gist.githubusercontent.com/Satyabsai/b3970e2c3d229de2c70f1def3007ccfc/raw/02dc6f7979a83287adcb6eeecddb5575bef3516e/data.json
******************** TASK.JSON file****************************
{
"id": "d9bafed3-2b89-4a4e-89b8-21a3d8a4f1d3",
"name": "TestExecutor",
"friendlyName": "Execute ",
"description": "Executes",
"helpMarkDown": "",
"category": "Test",
"author": "s4legen",
"version": {
"Major": 5,
"Minor": 4,
"Patch": 0
},
"instanceNameFormat": "Execute Test Suite $(carlist)",
"inputs": [
{
"name": "category",
"type": "pickList",
"defaultValue": "Web",
"label": "Category",
"required": true,
"helpMarkDown": "Select the ",
"options": {
"mobile": "car",
"web": "truck",
"api": "Plan"
}
},
{
"name": "Color",
"type": "pickList",
"defaultValue": "Blue",
"label": "color",
"required": true,
"helpMarkDown": "Select the ",
"options": {
"nonProd": "Blue",
"prod": "Red"
}
},
{
"name": "Carlist",
"type": "pickList",
"defaultValue" :"BMWX7",
"label": "Carlist",
"required": true,
"helpMarkDown": "Select the list to execute",
"properties": {
"EditableOptions": "true",
"Selectable": "true",
"Id": "CarInput"
},
"loadOptions": {
"endpointUrl": "https://gist.githubusercontent.com/Satyabsai/b3970e2c3d229de2c70f1def3007ccfc/raw/02dc6f7979a83287adcb6eeecddb5575bef3516e/data.json",
"resultSelector": "jsonpath:$[*]",
"itemPattern": "{ \"value\": \"{value}\", \"displayValue\": \"{displayValue}\" }"
}
}
],
"execution": {
"Node16": {
"target": "index.js"
}
},
"messages": {
"TestSuiteLoadFailed": "Failed to load test from endpoint. Using default options."
}
}
**************
*************************
const tl = require('azure-pipelines-task-lib/task');
const axios = require('axios');
const TEST_ENDPOINT = 'https://gist.githubusercontent.com/Satyabsai/b3970e2c3d229de2c70f1def3007ccfc/raw/02dc6f7979a83287adcb6eeecddb5575bef3516e/data.json';
async function getValue(field) {
if (field === 'Carlist') {
try {
const response = await axios.get(TEST_ENDPOINT, {
timeout: 5000
});
return {
options: response.data.map(item => ({
value: item.value,
displayValue: item.displayValue
})),
properties: {
"id": "CarlistDropdown"
}
};
} catch (error) {
tl.warning(tl.loc('TestLoadFailed'));
}
}
return null;
}
async function run() {
try {
const color = tl.getInput('color', true);
const category = tl.getInput('category', true);
const carlist = tl.getInput('Carlist', true);
const result = await axios.post(tl.getInput('clicQaEndpoint'), {
testSuite,
category,
environment
}, {
timeout: 10000
});
tl.setResult(tl.TaskResult.Succeeded, `Execution ID: ${result.data.executionId}`);
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err.message);
}
}
module.exports = {
run,
getValue
};
********************
CAN SOMEONE TELL ME WHAT JSON RESPONSE IS ACCPETABLE BY AZURE TO POPULATE DROPDOWN DYNAMICALLY SOURCE IS api
1 Reply
Azure DevOps expects the response to match the itemPattern you've defined:
[ { "value": "BMWX7", "displayValue": "BMW X7" }, { "value": "AudiQ5", "displayValue": "Audi Q5" } ]
Each item must be a flat object with value and displayValue keys. If your endpoint returns anything nested or missing those keys, the dropdown will show “Not Found.”