Jump to content

notifications posted in a Slack channel?


linojon

Recommended Posts

hi, i would like to integrate notifications of plasticscm events from a repository into a slack channel. I found this post http://codicesoftware.blogspot.com/2015/01/integrating-plastic-scm-with-slack.html but its either not the same thing, or really confusing, or both. Whatever, i didnt get very far trying to follow it. Mostly at this point, all i want is a bot message to be posted in a channel when someone pushes a branch replication to a cloud repository (like you'd see with Slack's github integration). Is there an easy way to do this?

 

 

Link to comment
Share on other sites

Hi! We migrated to Plastic from Subversion where we had a working Slack integration.

 

What we did after moving to Plastic was to setup another Subversion channel (Slack has instructions for this). We changed the icon and name etc of the channel.

 

Then we modified the perl script (provided by Slack integration with Subversion) to work against Plastic (cm log) instead. We then added a small .bat file to call the perl script (could use any script language or even an .exe). We call the .bat file via a server-side trigger (after-checkin) that we setup in Plastic.

 

The after-checkin trigger may not be exactly what you need, but you can read more about this and other Plastic trigger types here:

https://www.plasticscm.com/documentation/triggers/plastic-scm-version-control-triggers-guide.shtml

 

Hope this helps to get you started!

Link to comment
Share on other sites

Here's another tip: To prevent the Slack posting from stalling/delaying the Checkin process, we want the trigger script to return very quickly.

 

To achieve this, we used the PsExec utility from Microsoft to spawn the perl script in a new non-interactive (asynchronous) process:

https://technet.microsoft.com/en-us/sysinternals/psexec.aspx

 

Here are the lines we use in our .bat file to split the trigger variables and call the (modified) perl script:

 

for /f "tokens=2,4,6 delims=:@" %%C in ("%PLASTIC_CHANGESET%") do (
    PsTools\PsExec.exe -d -accepteula perl "%~dp0\plastic-slack.pl" %PLASTIC_CHANGESET% %%C %%D %%E %PLASTIC_USER%
)

Link to comment
Share on other sites

Now, of course, it's cleaner to just pass %PLASTIC_CHANGESET% and %PLASTIC_USER% on to the perl script and do the string splitting there... ;)

 

Caveats:

 

* The trigger and script will run under the same user as the Plastic SCM server. On Windows this is often "NT AUTHORITY\SYSTEM". To debug your .bat file and perl script under this user, you can use the following command in the PsTools package from Microsoft (see PsExec in my last post) :

 

psexec.exe -i -s %SystemRoot%\system32\cmd.exe

 

* If your server has only an SSL port activated, the repserver: part of the selector passed in the %PLASTIC_CHANGESET% trigger variable may not contain a protocol identifier. This means "cm log" will fail if you pass the complete selector, since it assumes the plastic:// protocol instead of ssl://. You may then find that it works better if you simply omit the repserver: part.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...