Reputation: 1562
My custom build task is running on an agent, and its files are located at E:\agent_work\_tasks\MyTaskName_106598a6-d5ba-4038-8dc8-ba0172210a94\0.0.13
. Is there a way to use vsts-task-lib to get this path?
If I were able to get the task id, name, and version sourced from the task.json, I could determine the path myself by doing something like, tl.getVariable('Agent.WorkFolder') + '\\_tasks\\' + taskName + '_' + taskIdentifier + '\\' + taskVersion
.
I had my eyes on https://github.com/Microsoft/vsts-task-lib/blob/master/node/docs/vsts-task-lib.md#taskgetTaskVariable, but wasn't sure of the variable names to use or if this was even along the right path.
Upvotes: 0
Views: 499
Reputation: 33698
You can get current path by using __dirname
(nodejs) or $PSScriptRoot
(powershell) in your build/release task extension.
For example:
NodeJs:
console.log(__dirname)
PowerShell:
Write-Host $PSScriptRoot
Upvotes: 1