How to Hide or Remove Unwanted ‘Task Group Parameters’ in Azure DevOps
As someone immersed in the nitty-gritty of CI/CD pipelines and DevOps practices, I’ve encountered my fair share of head-scratchers. But there’s one particular issue that’s more of a thorn in my side than most: the seemingly random, automatically generated parameters in Azure DevOps Task Groups. It’s like the system has a mind of its own, tossing in parameters willy-nilly.
Take, for instance, a line from my PowerShell script whimsically deciding to moonlight as a parameter in a Task Group.
And it looks like this in the pipeline, Seriously?
It’s almost laughable — what am I supposed to assign to a parameter like “throw ‘query is required.’”?
But fret not, fellow DevOps enthusiasts, for I’ve wrestled with this beast and come out with a couple of clever tricks up my sleeve:
1- Removing Unwanted Parameters in Azure DevOps Task Groups
When you’ve had enough of those uninvited parameters, here’s how you show them the door:
Export the Task Group: Head over to Task Groups in Azure DevOps and export your desired Task Group, which generates a .JSON file.
Edit the JSON File: Open the exported JSON file with your preferred editor (Visual Studio Code is my go-to). Scroll down to locate the inputs array, which lists all the parameters defined for the Task Group.
Delete Unnecessary Inputs: Identify the inputs you wish to remove and delete them from the array.
Import the Modified JSON: Save your changes and import the edited JSON back into Azure DevOps to establish a new Task Group.
Once we import it, its obvious that we got rid of the parameters.
Enjoy the Cleanup: Deploy the Task Group in your pipeline and revel in the absence of unnecessary parameters.
A word of caution: This fix is stable until any further modifications are made to the Task Group. Post-edit, the pesky parameters might resurface, which is why many are leaning towards the reliability of YAML pipelines and templates!
2- Hiding unwanted parameters in Azure Devops Task Groups
Sometimes, removal isn’t an option, and concealing the parameters is more appropriate. Here’s how:
Export the Task Group: Similar to the previous method, start by exporting the Task Group to obtain a .JSON file.
Open and Edit the JSON File: Use your favorite JSON editor to open the file and navigate to the inputs section.
Implement a Visibility Rule: For the parameters you wish to hide, add the line “visibleRule”: “1 = 2”.
- This rule effectively keeps the parameter invisible by setting a condition that’s never true.
The visible rule lets you define when something is visible, if you just add an expression that is never true it will remain invisible.
Import and Clean Up: Save your edits, import the JSON back as a new Task Group, and tidy up any naming redundancies (like the appended “- Copy”).
Verify in the Pipeline: Insert the Task Group into your pipeline. The parameters with the visibleRule applied will stay hidden but operational as internal variables.
As we can see , now I only see the “AssemblyInfo.AssemblyVersion” parameter as i hid the “throw ‘query is required.’” parameter.
In the ever-evolving and sometimes chaotic domain of DevOps, these workarounds add two more tools to your arsenal. It’s about making the process more manageable, one step at a time. Let’s keep innovating and streamlining our workflows!