June 15, 2020

Web triggers for Plastic SCM Cloud are here!

You can now hook web triggers to Plastic SCM operations. It has been a reality for years on the on-premises Plastic SCM Server, but now Plastic Cloud also supports it!

Do you remember we recently released cloud2? Web triggers is one of the new features in the new Cloud. Stay tuned because there's much more to come 🙂

What a web trigger is?

Web triggers enable the Plastic Cloud server to connect to an external system. The Plastic Cloud server executes HTTPS POST requests to a configured URL, and it sends a JSON payload containing useful information about the Plastic operation.

You use the endpoint that received the JSON payload to create amazing extensions to the Plastic Cloud. For example, enforce that the changesets are created with a valid comment or update a .rss file, which can be used by RSS aggregators to notify new changes on the repository.

How can you create a web trigger?

It's straightforward! Open a command-line window and use the cm trigger create command. Here you have an example for the "after create repository" operation:

>cm trigger create after-mkrep CiNotifierWebTrigger "webtrigger https://wh.automate.io/webhook/5f2s3sasba3d64035e8571c" --server=catacroquer@cloud
Trigger created on position 1.

We have a lot of different Plastic SCM operations to attach your web trigger to. Check the complete list here.

Applications?

Infinite possibilities! From building a checkin notification system to sending deployment requests to your production machines.

Let me share a couple of options:

  • A Slack integration that notifies the team when new changesets are created in the main branch.
  • An SMS alert system for relevant SCM operations.

You can, of course, build and use your own webserver to process the web trigger requests made from the Plastic Cloud server. This will give you the freedom to make complex triggers. But if you don't want to do super-specific stuff, you can use services like https://automate.io or https://zapier.com/. They integrate with a great variety of well-known applications and make the process easy.

Notify new changes by Slack

I used automate.io; it gives me a web trigger endpoint that I can use at the cm tr mk command:

cm trigger create after-checkin CiNotifierWebTrigger "webtrigger https://wh.automate.io/webhook/5ee22e5f9f3ca20d3b1f9aed" --server=catacroquer@cloud
Trigger created on position 2.

It also integrates nicely with Slack. The automate.io bot configuration looks like this:

Finally, check the Slack message you get when a user creates a new changeset:

Relevant SMS notification system

It is always useful to know when certain operations happen. "make repository", "remove repository" or "new release available" are a few of them.

We can use as many web triggers as we need to create an SMS notification system for your relevant SCM operations.

Again, automate.io gives me a fast way to integrate with Nexmo, a communication system that supports sending SMS programmatically. All I need is the web trigger endpoint and use it to create the Plastic SCM triggers:

>cm trigger create after-mkrep RelevantOpsWebTrigger-mkrep "webtrigger https://wh.automate.io/webhook/5f2s3sasba3d64035e8571c" --server=catacroquer@cloud
Trigger created on position 1.

>cm trigger create after-rmrep RelevantOpsWebTrigger-rmrep "webtrigger https://wh.automate.io/webhook/5f2s3sasba3d64035e8571c" --server=catacroquer@cloud
Trigger created on position 1.

>cm trigger create after-mklabel RelevantOpsWebTrigger-mklabel "webtrigger https://wh.automate.io/webhook/5f2s3sasba3d64035e8571c" --server=catacroquer@cloud
Trigger created on position 1.

When one of those operations happen, I get an SMS alert like this:

Enjoy and share!

Don't hesitate to contact us if you need help with a trigger; we will be more than happy to help. If you want to share the web trigger applications you are going to build, that would be awesome!

No comments:

Post a Comment