Jump to content

Triggers: after-replicationwrite and PLASTIC_REPLICATION_ID


Xonman

Recommended Posts

Hi,

I'm trying to setup a trigger which will cause an automated build to take place on certain branches of certain repositories. Our developers work on a local server, and replicate to a central server when they're ready, so it appears that we can't use after-checkin because as far as I can tell that only triggers on the server the checkin happens on, which would be the developer's local machine.

This leaves the replicationwrite triggers. Unfortunately I can't see any way of making these triggers useful. The docs specify I should see a PLASTIC_REPLICATION_ID environment variable on the script that's running. I do, but it's value is an empty string in all cases.

Ok, what else can we use? I see there's also a PLASTIC_REPLICATION_ID environment variable, great. It's even got a value. What is this value? It doesn't correspond with anything else anywhere in Plastic, and the trigger documentation is the one and only mention of a replication ID across all of the docs.

 

Ideally I would like to use the replication ID, since a developer could replicate 3 or 4 commits at once, and using the replication ID, I could identify the latest changeset and only initiate a build on that changeset. How do I resolve the replication ID into something meaningful?

 

I've attached the output of every environment variable from the triggered script in case it's helpful:

Quote

[1/2/2017 - 14:28:19] - Replication triggered:
    LANG = en_AU.UTF-8
    TERM = xterm
    PLASTIC_CLIENTMACHINE = Server: xyz
    PLASTIC_SERVER = xyz:8087
    LANGUAGE = en_AU:en
    LD_LIBRARY_PATH = /opt/plasticscm5/mono/lib:
    MONO_MWF_SCALING = disable
    PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
    MONO_PATH =
    SHELL = /bin/bash
    SHLVL = 0
    SUDO_COMMAND = <path to plasticd> --daemon
    PLASTIC_BRANCH =
    PLASTIC_USER = xyz
    PWD = <path to plastic>
    USERNAME = <plastic user>
    SUDO_UID = 0
    SUDO_GID = 0
    MONO_MWF_MAC_FORCE_X11 = 1
    LOGNAME = <plastic user>
    PLASTIC_REPLICATION_ID = 253
    USER = <plastic user>
    SUDO_USER = 
 

 

Link to comment
Share on other sites

Hi calbzam, thanks for the reply.

That does help, and I've worked out that I can see which changeset was included in the replication by querying the changeset table with the replication log id, but I still have a problem.

It seems that plastic assumes the cm find command is being run on the active workspace, so if I run the query from anywhere else, cm complains that I need to include an "on repositories" clause. The problem is I don't necessarily know which repository was replicated.

The triggers documentation says the environment variable PLASTIC_BRANCH should include a branch spec to the trigger, but for the after trigger the variable is empty. It is correctly populated for the before trigger, but the before trigger does not include the replication log id (which makes sense because the replication hasn't happened yet).

 

For now I can get around this by repeating the query for every repository, but am I doing something wrong to not have that variable populated? If I could get the branch spec from the variable, it would save a lot of time.

Link to comment
Share on other sites

Thanks Carlos, having that field available will make things a lot easier.

In the mean time I've gotten around it by querying changesets on all repositories and finding the matching repllogid. It works, but is much slower than if I could know the branch already.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...