EdDev Posted January 5, 2013 Report Share Posted January 5, 2013 Hello, After reviewing the triggers documentation I could not answer this hot to: I will like to issue a pre-checkin validation on "release" branches (only) by triggering the CI to build the project and run the Unit Tests. There seems to be no environment variable that specifies the repo and branch in question. I will like to perform this using Jenkins. Thanks, Ed. Link to comment Share on other sites More sharing options...
calbzam Posted January 8, 2013 Report Share Posted January 8, 2013 Hello, There isn´t a specific environment variable to retrieve the repo and branch but when you run a trigger (before or after) there is a line with this information, so, I think you can parse the first line and get the desired fields. Here you have an example of how this first line looks like:. "CH "/" DIR#br:/main;changeset:5@rep:Carlos@repserver:HERMES:8084" You will always have the root item ("/") in the first position so it's very useful for your purposes. Tell me if it works for you. Link to comment Share on other sites More sharing options...
EdDev Posted January 8, 2013 Author Report Share Posted January 8, 2013 Hello, Thank you for the feedback. Unfortunately, I was not successful in making a simple trigger work (with environment variables only), so my question was too advance in the first place :-). Hope I am not messing up this forum thread by asking now for help to reach the goal through a simpler test. I tried to check triggers by using a simple one that does not affect the repo to much: triggers on Label creation. On post action, I registered a script which should send an email with the information of the new added label. I'm using a Linux Server (Ubuntu 12.04) for the PlasticSCM Server and W7 for the PlasticSCM client. Script File: /home/scm/plasticscm_trigger_script_label.run PlasticSCM folder: /opt/plasticscm4 Command to register the trigger: cm mktr after-mklabel "notify_on_label" "/home/scm/plasticscm_trigger_script_label.run" 1 notify_on_label /home/scm/plasticscm_trigger_script_label.run S-1-5-21-66943981-1140478103-145704350-8906 after-mklabel * The script works well when calling it directly (sending me an email with blanks in the locations of the variables). When adding a LABEL, a notification is presenting about the failure to perform the trigger. I'm suspecting permission issues, but have no idea from what permission context the trigger is issued. Hope someone could help, Thanks, Ed. Link to comment Share on other sites More sharing options...
manu Posted January 9, 2013 Report Share Posted January 9, 2013 Hi Ed, ok, I have a question, is the trigger in the same machine as the Plastic SCM server? The scrips are needed to be stored in the server side, you just need to make sure the server is able to read/execute it. This is a small ruby trigger that checks if comment has been added: c = ENV['PLASTIC_COMMENT'] if (c == nil || c == '') then exit(1) end cm maketrigger before-mklabel /home/ServerPathToScript/validate-label.rb You can try to add the ruby trigger, tell me if it works. Link to comment Share on other sites More sharing options...
EdDev Posted January 9, 2013 Author Report Share Posted January 9, 2013 Hi Manu, Yes, the script is on the Linux machine. Tried the same with the one you provided (just added the name of the trigger which is missing above). Here is the result: Configuration: vcs@e-vcs-server:~$ cm maketrigger before-mklabel check_comment_on_label /home/vcs/validat e-label.rb Trigger created on position 1. vcs@e-vcs-server:~$ cm lstr 1 check_comment_on_label /home/vcs/validate-label.rb S-1-5-21-66943981-1140478103-145704350-8906 before-mklabel vcs@e-vcs-server:~$ ls -la total 52 drwxr-xr-x 5 vcs vcs 4096 Jan 9 17:14 . drwxr-xr-x 4 root root 4096 Jan 1 11:40 .. -rw------- 1 vcs vcs 6660 Jan 2 20:02 .bash_history -rw-r--r-- 1 vcs vcs 220 Jul 26 17:13 .bash_logout -rw-r--r-- 1 vcs vcs 3572 Jul 26 18:23 .bashrc drwx------ 2 vcs vcs 4096 Jul 26 17:16 .cache drwxrwxr-x 2 vcs vcs 4096 Jul 29 11:00 download drwxrwxr-x 2 vcs vcs 4096 Jan 2 14:20 .plastic4 -rw-r--r-- 1 vcs vcs 761 Jul 26 18:23 .profile -rwxrwxrwx 1 vcs vcs 70 Jan 9 17:14 validate-label.rb -rw------- 1 root root 6511 Jan 2 10:28 .viminfo vcs@e-vcs-server:~$ pwd /home/vcs vcs@e-vcs-server:~$ Error on the client while attempting to add a LABEL: The trigger before-mklabel [check_comment_on_label] failed. Something is wrong :-/ Thanks, Ed. Link to comment Share on other sites More sharing options...
manu Posted January 9, 2013 Report Share Posted January 9, 2013 Did you inserted a comment? Link to comment Share on other sites More sharing options...
EdDev Posted January 9, 2013 Author Report Share Posted January 9, 2013 Ok, after several hours it works.. Huray! :-) The Ruby script works now... just added the "ruby" in front of the command when registering the trigger. However, I could not manage to run any "regular" application (like ssmtp). The problem is indeed with the permissions. Looks like the PlasticSCM is installed on Linux with a user called "plasticscm" (what I mean is, the files are run from this user context). The problem with this is, that this user has no home directory and no PATH is used by it, making any call to most application to fail as it is not looked up in the regular PATH. When specifying the full path of the application all plays well. Another issue that seems problematic here is permissions to create files, this also requires special care as we can create it only on /tmp. I think this is either an installation problem or the manual for Linux installation requires some editing (like adding plasticscm as a regular user?). Thank you for the support so far. Thanks, Ed. Link to comment Share on other sites More sharing options...
manu Posted January 10, 2013 Report Share Posted January 10, 2013 Great, happy to know it's working. The problem is indeed with the permissions. Looks like the PlasticSCM is installed on Linux with a user called "plasticscm" (what I mean is, the files are run from this user context). The problem with this is, that this user has no home directory and no PATH is used by it, making any call to most application to fail as it is not looked up in the regular PATH. When specifying the full path of the application all plays well. Another issue that seems problematic here is permissions to create files, this also requires special care as we can create it only on /tmp. I think this is either an installation problem or the manual for Linux installation requires some editing (like adding plasticscm as a regular user?). I wasn't aware about the missing PATH for the "plasticscm" user, definitely we have to check how to improve that. Best regards, Manu. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.