[Perforce Plugin] support for build parameters in "Client name format for slaves"

114 views
Skip to first unread message

Stuart Rowe

unread,
Apr 30, 2014, 6:43:44 PM4/30/14
to jenkin...@googlegroups.com
Our builds are typically parameterized with a "branch" to build against. The client specs used by our nodes are already using a <nodename>_<branch> naming convention. I would like to use this format for the slave client names in the peforce plugin.

The only supported tokens are:
${basename} - The client name as configured in the above section
${hostname} - The hostname of the slave
${nodename} - The name of the slave in the CI server. Use this with caution.
${hash} - The hash code of the slave name

Because of this limitation, our underlying builds handle syncing, but I would really like to start using the perforce plugin to take advantage of the Jenkins features related to SCM.

Would it be difficult to support additional tokens in this field? Or is this task relatively easy for someone without any Jenkins plugin development experience?

Thanks,
Stuart


Stuart Rowe

unread,
May 1, 2014, 2:50:41 PM5/1/14
to jenkin...@googlegroups.com
I forked the perforce-pluigin repo and I believe the changes required are straight forward. I'm not currently set up to build / test Jenkins plugins (I'll look into this when I have time). Should I submit a ticket for this request?

Here are the changes I'm proposing:

old new ... ... @@ -1715,7 +1715,7 @@ public class PerforceSCM extends SCM {
1715 1715        String p4Client = this.p4Client;
1716 1716        p4Client = MacroStringHelper.substituteParameters(p4Client, build, env);
1717 1717        try {
1718 -            p4Client = getEffectiveClientName(p4Client, buildNode);
1718 +            p4Client = getEffectiveClientName(p4Client, buildNode, env);
1719 1719        } catch (Exception e) {
1720 1720            new StreamTaskListener(System.out).getLogger().println(
1721 1721                    "Could not get effective client name: " + e.getMessage());
... ... @@ -1726,10 +1726,11 @@ public class PerforceSCM extends SCM {
1726 1726    private String getDefaultEffectiveClientName(AbstractProject project, Node buildNode, FilePath workspace)
1727 1727            throws IOException, InterruptedException {
1728 1728        String basename = MacroStringHelper.substituteParametersNoCheck(this.p4Client, getDefaultSubstitutions(project));
1729 -        return getEffectiveClientName(basename, buildNode);
1729 +        Map<String,String> emptyEnv = new Hashtable<String,String>();
1730 +        return getEffectiveClientName(basename, buildNode, emptyEnv);
1730 1731    }
1731 1732
1732 -    private String getEffectiveClientName(String basename, Node buildNode)
1733 +    private String getEffectiveClientName(String basename, Node buildNode, Map<String,String> env)
1733 1734            throws IOException, InterruptedException {
1734 1735
1735 1736        String p4Client = basename;
... ... @@ -1757,6 +1758,7 @@ public class PerforceSCM extends SCM {
1757 1758            substitutions.put("hostname", host);
1758 1759            substitutions.put("hash", hash);
1759 1760            substitutions.put("basename", basename);
1761 +            substitutions.putAll(env);
1760 1762
1761 1763            p4Client = MacroStringHelper.substituteParametersNoCheck(getSlaveClientNameFormat(), substitutions);
1762 1764        }

Niksan

unread,
May 20, 2014, 5:25:28 AM5/20/14
to jenkin...@googlegroups.com
Thanks to Perforce themselves wading in with their size 12's you would come to the conclusion the current plugin has gone stale.

It's easy to set up a test mechanism though, even easier if you use the free version of IntelliJ.

Oleg Nenashev

unread,
May 20, 2014, 3:19:41 PM5/20/14
to jenkin...@googlegroups.com, Rob Petti
@Stuart
Unfortunately, the development/maintenance of the Perforce plugin is in stuck for a while.
There're many reasons (including Perforce guys), but currently nobody is ready to continuously maintain the plugin.

I recommend to submit a PR for your case.
Variables handling is on of biggest issue in Perforce Plugin, hence it should be definitely fixed.
I'm working on a general-purpose variables solution in a background, so I could just merge your changes at some point.

Best regards,
Oleg Nenashev

вторник, 20 мая 2014 г., 13:25:28 UTC+4 пользователь Niksan написал:

Stuart Rowe

unread,
May 20, 2014, 3:25:23 PM5/20/14
to jenkin...@googlegroups.com
I actually submitted a pull request on May 2, I've been waiting for it to get reviewed and merged (https://github.com/jenkinsci/perforce-plugin/pull/52


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/hn_8YFGNmuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages