Skip to end of metadata
Go to start of metadata

After installing the Timestamper Plugin, you have to configure each job by manually checking the "Add timestamps to the Console Output" option.

Obviously, it can be a bit cumbersome. But here comes the great groovy script console again.
With the following simple script, you can activate the option on every jobs of your server in just one go.

Backup your config before playing with those scripts, as always

for (item in Hudson.instance.items) {
  println("\njob: $item.name")
  hasTimestamper = false;
  item.buildWrappersList.each {
    if (it instanceof hudson.plugins.timestamper.TimestamperBuildWrapper) {
      hasTimestamper = true;
    }
  }
  if (!hasTimestamper) {
    println(">>>>>>>> Adding timestamper right to $item.name")
    item.buildWrappersList.add(new hudson.plugins.timestamper.TimestamperBuildWrapper());
    item.save()
  }
}
  • No labels

6 Comments

  1. Another way to do this is with the Configuration Slicing Plugin which supports the Timestamper plugin now.

  2. I use "replace" instead of "add" because multiply lines appear:

     item.getBuildWrappersList().replace(new  hudson.plugins.timestamper.TimestamperBuildWrapper() );

    1. Since the script, as written, is checking to see if timestamper is already applied, adding has the same effect as replacing.

  3. Using "item.buildWrappers" returns a collection with the wrong kind of classes being checked later. Use "item.buildWrappersList" instead,

    1. I've modified the script to reflect that needed change.

  4. For who is new to jenkins and wondering where this script should be executed

    "/script" is the end point on jenkins-version: 1.629  (manage jenkins->Script Console)

    Ex. http://YOUR_JENKKINS_URL/script