Can you trigger a release in TFS 2015.2 from another release definition execution? Was the request from one of the teams. To fulfill this requirement, if you are using VSTS or TFS2017, you can use the extension “VSTS Trigger” available in marketplace. But this is not usable in TFS 2015.2 as it does not have the Personal Access Token feature. The PowerShell script described in this post will let you trigger a release from another release.
Parameters of the script
- User = should be a user added to team project “Release Administrators” security group and should have permission to view project level information.
- Password = Password of the user
- collectionUri = Team foundation server collection url
- TeamProject = Team Project Name
- ReleaseDefId = Release Definition Id
- TriggerDescription = Description for triggering release
- ArtifactAlias = Alias of the artifact
- ArtifactId = Id of the artifact to use
The script (available here to download)
You can execute this script with PowerShell as shown in below example.
.\TriggerRelease.ps1 -User 'yourdoamin\username' -Password 'userpassword' -collectionUri 'http://yourtfs:8080/tfs/yourcollection' -TeamProject 'yourteamprojectname' -ReleaseDefId 'releasedefinitionid' -TriggerDescription 'Creating using PS' -ArtifactAlias 'buildaliasusedinrelease' -ArtifactId 'buildid' -Verbose
This would trigger a release in TFS 2015.2
You can use the same script in another release dentition as inline PowerShell script or as a PowerShell task after making the script here available in the source control repository. This script can be further enhanced with TFS REST API to obtain required build names and IDs etc. with the required logic.