Create your first trigger
Follow this workflow to create your first trigger for automation.
読み終わるまでの所要時間 1 分最終更新 9ヶ月前
This page shows a workflow for how to create and edit a trigger that validates your label names through the command line:
- View available triggers.
- Create the trigger.
- View a list of your existing triggers.
- Edit the trigger.
- Delete the trigger.
View trigger types
To associate a user script with a client or server event, you need to create a trigger. To show a list of all supported trigger types in your command line, you can use the command:
showtypescm trigger showtypesCreate a trigger
If your label names are created according to a given naming standard, you can create a trigger that validates label names. To create this trigger on Windows, you can use the following command:
createcm trigger create before-mklabel "check label name" "ruby c:\plastic\triggers\validate-label.rb"This is a sample Ruby script () that checks that the label name starts with :
validate-label.rbreleaseif (ENV['PLASTIC_LABEL_NAME'] !~ /^release/) then exit(1) endThe script picks the name of the label from the environment variable and checks the contents against the regular expression , which matches a string that starts with . If the label name doesn't match ( operator), the trigger returns the exit code , which means the trigger fails and doesn't allow the operation to finish.
PLASTIC_LABEL_NAME^releasereleaserelease!~1mklabelList triggers
To see any triggers that you create, you can use the list command to show all the triggers of the same type you created:
>cm trigger list before-mklabel1 Validate label c:\tmp\triggers\validate-label.bat dave
Edit triggers
To modify the script that this trigger is pointing to, you can use the trigger command. You need to indicate the trigger type and the trigger position, which is the first index that the list triggers command returns (1 in this case):
editcm trigger edit before-mklabel 1 --script="c:\tmp\other-script.bat"Delete triggers
To remove a trigger, you can use the trigger . You need to indicate the trigger type and position:
deletecm trigger delete before-mklabel 1