Final Atomic Buster Posted January 16 Report Share Posted January 16 Hi, Apologies if this was already asked somewhere. I couldn't find any references when searching. I'm new to using Triggers (and Ruby!), and it's making me feel quite dumb 🤣. I've been trying to get the after-update trigger working (a ruby script will get the current changeset and write it to a text file). I know I can get the trigger to run (as with some small changes to the script, I can see it does actually run). But I'm unable to use the environment variable PLASTIC_FINAL_CHANGESET to get the changeset. First, can someone else do a sanity check for me and just make sure that environment variable works? If you're already using it on your repos, just seeing it's working elsewhere would be great to know it's not just broken. Reason I ask, was in my search, I did find there was a bug fix in April 2022 for when it was broken (https://www.plasticscm.com/download/releasenotes/11.0.16.6898), so I wonder if it somehow became broken again... Next, what am I doing wrong? Here's my ruby script: #!/usr/bin/env ruby File.open("changeset.txt", "w") do |f| f.write(@PLASTIC_FINAL_CHANGESET) end I've also tried caching the result first, but it still doesn't work: #!/usr/bin/env ruby changeset = ENV["PLASTIC_FINAL_CHANGESET"] File.open("changeset.txt", "w") do |f| f << changeset end Am I just completely off track with my script and trigger set up? I definitely feel like it! Any help here is much appreciated. Thanks in advance! Link to comment Share on other sites More sharing options...
blue Posted January 30 Report Share Posted January 30 Hi @Final Atomic Buster, I have tested the trigger with the ruby script. the variable works fine. do you receive any error message? Link to comment Share on other sites More sharing options...
Final Atomic Buster Posted January 30 Author Report Share Posted January 30 I don't see errors. Where would they appear? Remember I'm running as after-update trigger on Plastic, and not using any command line (using Plastic SCM client). Link to comment Share on other sites More sharing options...
blue Posted January 30 Report Share Posted January 30 @Final Atomic Buster Quote But I'm unable to use the environment variable PLASTIC_FINAL_CHANGESET to get the changeset. Can you please explain why you believe you cannot use it? Link to comment Share on other sites More sharing options...
Final Atomic Buster Posted January 31 Author Report Share Posted January 31 Hi, I'm really sorry. Since it's been two weeks and I had to move on to other tasks, I can't seem to figure what I had done previously to test my original statement in the opening post. However, I'm confident that what I wrote then was accurate (Environment Variable not working), as I remember being thorough and double checking my results as I was writing the post. I can confirm that right now I still cannot get the environment variable working. Also, I am unable to get a basic test of a ruby script working using the after-update trigger. I'm likely forgetting how I managed to get that part setup. This is probably where I first need some help. I can confirm I can get the ruby script to run if I just directly run it from a Terminal. Doing this seems to not read the environment variable correctly (the resulting text file is blank). But if I change the ruby script to just write some plain text, that works (the resulting text file contains the test text). So I guess the first thing I need help on is how to actually create the after-update trigger. I've been using both: cm trigger create after-update "Save ChangeSet" SaveChangeSet.rb cm trigger create after-update "Save ChangeSet" SaveChangeSet.rb --server=<server> And neither work when I run Update Workspace in Plastic App. The SaveChangeSet.rb file is in the root of the repo. I can confirm the triggers are there when I do either: cm trigger list cm trigger list --server=<server> What am I doing wrong here?? Thanks in advance! Link to comment Share on other sites More sharing options...
blue Posted January 31 Report Share Posted January 31 @Final Atomic Buster My testing environment was Windows when I create a trigger I had to pass the where ruby located otherwise my testing environment did not know what to do with .rb. Plus, I am using the latest version of Plastic SCM. cm trigger create after-update "TriggerName" "<path where ruby installed>\ruby.exe <path of srcirpt>\exampleTrigger.rb" --server=<MyOrgName>@cloud Link to comment Share on other sites More sharing options...
Final Atomic Buster Posted January 31 Author Report Share Posted January 31 Would that mean any other person who uses activates the trigger would need their ruby installed in the same location? If so, then how do we handle it on mixed OS? (Windows and OSX, in our case) Thanks for your example. I'll try that later today when I get a chance. Link to comment Share on other sites More sharing options...
blue Posted February 1 Report Share Posted February 1 @Final Atomic Buster - I am afraid that I am a newbie in Ruby as well. If you are using different OS, you might want to use ruby command after you add that ruby in the environment variable. The screenshot below is from Plastic SCM Triggers : https://docs.plasticscm.com/triggers/plastic-scm-version-control-triggers-guide#Samples. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now