Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find System.TeamProjectId for a project in Azure Devops

Tags:

azure-devops

I need this Id upfront but I can't seem to find it anywhere online?
The documentation only refers to it as a system variable.

Context: I have multiple projects and I want to identify a project during CI so it can run a powershell script hosted in another repository.

like image 482
grmbl Avatar asked Dec 20 '18 09:12

grmbl


People also ask

What is System ArtifactsDirectory?

System.ArtifactsDirectory. The directory to which artifacts are downloaded during deployment of a release. The directory is cleared before every deployment if it requires artifacts to be downloaded to the agent.

What is system access token?

System. AccessToken is a special variable that carries the security token used by the running build.

Where are Azure DevOps project settings?

Open Settings>Process Choose the Azure DevOps logo to open Projects. Then choose Organization settings.

Where is build SourcesDirectory?

$(Build. SourcesDirectory) : The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s By default, new build definitions update only the changed files. You can modify how files are downloaded on the Repository tab.


1 Answers

You can get the all team projects id with REST Api:

 https://dev.azure.com/{organization}/_apis/projects?api-version=5.0-preview.3

Results:

 {
  "count": 3,
  "value": [
    {
      "id": "eb6e4656-77fc-42a1-9181-4c6d8e9da5d1",
      "name": "Fabrikam-Fiber-TFVC",
      "description": "Team Foundation Version Control projects.",
      "url": "https://dev.azure.com/fabrikam/_apis/projects/eb6e4656-77fc-42a1-9181-4c6d8e9da5d1",
      "state": "wellFormed"
    },
    {
      "id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
      "name": "Fabrikam-Fiber-Git",
      "description": "Git projects",
      "url": "https://dev.azure.com/fabrikam/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
      "state": "wellFormed"
    },
    {
      "id": "281f9a5b-af0d-49b4-a1df-fe6f5e5f84d0",
      "name": "TestGit",
      "url": "https://dev.azure.com/fabrikam/_apis/projects/281f9a5b-af0d-49b4-a1df-fe6f5e5f84d0",
      "state": "wellFormed"
    }
  ]
}

You don't even need use Postman or create Http request, just enter the API url above in the browser.

like image 193
Shayki Abramczyk Avatar answered Sep 24 '22 12:09

Shayki Abramczyk