KBEC-00093 - Using metacharacters as separators in properties

Article ID:360032831692
1 minute readKnowledge base
On this page

Description

When creating and referencing property values:

  • If you use slash:

      /

    then most of the DOS scripts work fine when expanded, but other shells complain.

  • If you use backslash:

      \

    then the Perl scripts cancel them out entirely when they are expanded.

Solution 1

Keep all of your properties with forward slashes in them, like

            ectool setProperty /myJob/forwardPath   "c:/ea/scripts"

When you want to use it in Perl, use it directly.

If Perl is passing it to a Windows command through "system()", convert the slashes using Perl

            s'/'\\'g;

Now for the tricky one, if you need it in a Windows command directly, use

            dir $[/javascript myJob.forwardPath.replace(/\//g, '\\')]
Solution 2

Keep all of your properties with backslashes in them, like

            ectool setProperty /myJob/ windowsPath "c:\ea\scripts"

When you want to use it in Perl, use:

            my $windowsPath = "$[/javascript myJob.windowsPath.replace(/\\/g, '\\\\')]";

If you need it in a Windows command directly, use it directly.

When creating property names:

  • If you use square brackets/braces:

      []

    then the property must be encapsulated in square brackets to avoid property sheet expansion.

This works for specific functions, such as creating a link on a job, but there are drawbacks. The property cannot be edited or deleted from the web interface.
Solution

Keep all square brackets in a property name, like

            ectool setProperty "/myJob/report-urls[This property name has [some square bracket] text in it]" "https://google.com"
This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.