GroovyProcessorBase confusing results.

Create issue
Issue #6 resolved
Former user created an issue

On line 143 in the file GroovyProcessorBase.java I see the line ... log.warn(buildLogger.addBuildLogEntry(new SimpleLogEntry("Disabling task [" + td.getUserDescription() + "]")));

What is confusing me is why this line does not show up when value equals False. Below is a log file that evaluated to false but does not have the log lines. Its almost as if the if statement is containing both lines instead of the normal one on line 140.

09-Mar-2016 12:00:02 Groovy Shell starting 09-Mar-2016 12:00:02 Groovy script if ( nff_WIPE_ENCFS.equalsIgnoreCase("TRUE") ) { 31-Dec-1969 19:00:00 return "False" 31-Dec-1969 19:00:00 } 31-Dec-1969 19:00:00 else { 31-Dec-1969 19:00:00 return "True" 31-Dec-1969 19:00:00 } evaluated to [False] 09-Mar-2016 12:00:02 tasks list not set, skipping

Please let me know what I missed so I can understand the code better thanks!

Comments (3)

  1. Julius Hutuleac repo owner

    if (td.getUserDescription().matches(expression)) { if(value.equalsIgnoreCase("true")) td.setEnabled(false);

                        log.warn(buildLogger.addBuildLogEntry(new SimpleLogEntry("Disabling task [" + td.getUserDescription() + "]")));
                    }
    

    So, the idea is to disable particular tasks, lets see a sample.

    For example we have 2 tasks in a job with the following names:

    • "Task only for Linux"
    • "Task only for Windows"

    You could write a small script to check OS version and return a regular expression to disable the useless one. For example:

    if (os.equals("Linux")) return ".Windows." else return ".Linux.";

    You should not return a simple True/False but a regular expression that would match all tasks you want to disable (Unless you put in task description True/False).

    Try in you example to put in the task decription in Bamboo the string "False"

  2. Former user Account Deleted

    FYI: By the way both cases work as desired just not as expected.

    This is the Condition

    if ( WIPE_ENCFS.equalsIgnoreCase("TRUE") ) {
      return "False"
    }
    else {
    return "True"
    }
    

    This is the task matcher

    \(initialize autotester cond\).*
    

    This is the other case:

    Groovy script if ( WIPE_ENCFS.equalsIgnoreCase("TRUE") ) { 31-Dec-1969 19:00:00 return "False" 31-Dec-1969 19:00:00 } 31-Dec-1969 19:00:00 else { 31-Dec-1969 19:00:00 return "True" 31-Dec-1969 19:00:00 } evaluated to [True] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Initialize Autotester] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) InitUnit Autotester] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Operational Autotester] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Set Production ESN] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Lock Production ESN] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License ACCECC] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License ECC] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License ECCMQV] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License KCDSA] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License PS] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License SCAP] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License HSMFS] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License KEYSF] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License SEEUE] 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Nopclearfail]

    What I am wondering is why I do not see this line 21-Mar-2016 20:11:58 Disabling task [(initialize autotester cond) Add License SEEUE] in the first case as it is outside the if check that tests whether condition equals true. Meaning regardless of what the condition says these Disabling task lines should appear.

  3. Julius Hutuleac repo owner

    You are right, it should appear if the task description is matching the expression regardless if it is not disabled.

    I can add some more logging there and blocks to ensure this is right.

  4. Log in to comment