I want to know the version control repository name by the Project name in Octopus through API. It would be great if u can get the branch name of repo also for the different-2 deployment environments.
And please excuse me, it’s just starting point with Octopus.
Good question. If you only have the name of the project, I recommend using the /api/[Space-ID]/projects?skip=0&take=100&partialName=[Project Name]
endpoint. That will return a list of projects that match that partial name. Generally, the more information provided, the shorter the list to loop through.
The Git repository information is stored in the PersistenceSettings property on the project.
If you are looking for the list of branches available to a given project, you can use the /api/[Space-Id]/projects/[Project-Id]/git/branches
end point. You can get the Project Id from the ID property on the project object from the above screenshot.
You also asked about getting the branch name in a deployment. The branch is selected when you create a release.
You can get a list of releases for a project by visiting the /api/[Space-ID]/Projects/[Project-Id]/Releases
endpoint. The list returned is ordered by creation date desc. The branch used for this particular release was auto-rollback
.
To find out the environments the release has been deployed to, you can use the /api/[Space-Id]/Releases/[Release-Id]/deployments
endpoint. That will tell you which environments the release has been deployed to along with the status of each deployment.
I hope that helps! If I missed something, let me know and I can amend the answer!