Reputation: 60411
In a custom vsts build task I want to know the path to the current build pipeline so that I can reuse the path to automatically calculate the path to the build drop folder.
In the vsts build portal where I create build pipelines they can be organized into folders. It's this folder path that I need to use in the build task. I can get hold of the name of the build pipeline from variables here: https://learn.microsoft.com/en-us/vsts/pipelines/build/variables?view=vsts&tabs=batch
But, there's no variable for the folder name. How can I get the folder name?
Upvotes: 0
Views: 4115
Reputation: 59055
The folder that the build definition lives under is purely a build definition thing -- it has no bearing on a running build, so it's not populated as a build-time variable.
You can retrieve the build definition by making a REST API call:
GET https://{accountName}.visualstudio.com/{project}/_apis/build/definitions/{definitionId}?api-version=4.1
. The account URI and build definition ID are available in a running build, and you can easily allow your script access to an OAuth token (populated in the SYSTEM_ACCESSTOKEN
environment variable) for authentication purposes.
This will return a JSON object, which contains a path
property. That's the path to your build definition.
Upvotes: 1
Reputation: 7079
You must be using an agent for your build pipeline. The agent may be hosted on VSTS or it may be on your premises.
Now, all the tasks in build definitions are executed on agent. Agent is simply a machine. Normally it uses below folders during build process.
So answer your question:
Upvotes: 0