Example triggers
Explore example triggers for automating workflows in Unity Version Control.
阅读时间1 分钟最后更新于 10 个月前
The following examples show you sample triggers that you can use to optimize your version control workflows.
Backup trigger
Create a trigger that fires after setting a workspace selector, located at at the server, and give it the name backup:
/home/scripts/plastic-backupcm trigger create after-setselector backup /home/scripts/plastic-backupValidation triggers
Label validation
Create a trigger called that fires before a label is created, that calls at server on port :
validate-label.batmyserver8084cm trigger create before-mklabel "Validate label" "c:\tmp\triggers\validate-label.bat" --server=myserver:8084Create a trigger that fires before a label is created in repository default and that label starts with bl or fix:
cm trigger create before-mklabel "label-bl-fix" "c:\tmp\triggers\label-bl-fix.bat" --filter="rep:default,bl*,fix*"Check in validation
Create a trigger that validates check in contents before the check in is actually performed in the repository, on a Windows server:
cm trigger create before-checkin ensure-code-stds "c:\plastic\triggers\checkcode.bat"Web trigger notifications
URI notification
Create a web trigger that fires after a check in action is performed, at URI and name it :
https://www.mysite.com/api/team/checkinNotify teamcm trigger create after-checkin "Notify team" "webtrigger https://www.mysite.com/api/team/checkin"A request body example of that web trigger would be as follows:
{ "PLASTIC_CHANGESET": "cs:2341@br:/main/task4638@rep:product@repserver:plastic.mysite.com:17590", "PLASTIC_CLIENTMACHINE": "DEV1HOST", "PLASTIC_COMMENT": "Fixing command line parsing", "PLASTIC_SERVER": "plastic.mysite.com:17590", "PLASTIC_SHELVE": false, "PLASTIC_USER": "dev1", "INPUT": [ "CH \"/src/main.c\" FILE" ]}
Discord notification
Create a web trigger that fires after a check in and send notifications from the server to the specified Discord channel:
cm trigger create after-checkin NotifyTeam "webtrigger-discord https://discordapp.com/api/webhooks/<channelId>/<token>" --server=localhost:18084Slack notification
Create a web trigger that fires after a check in and send notifications from the server to the specified Slack channel:
cm trigger create after-checkin SlackWebTrigger "webtrigger-slack https://slack.com/api/chat.postMessage/<channelId or UserId>/xoxb-SlackBotToken" --server=localhost:18084