Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

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. Unknown User (jacob_robertson)

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

  2. Unknown User (yurymilchenko)

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

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

    1. Unknown User (dankirkd)

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

  3. Unknown User (josesa)

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

    1. Unknown User (dankirkd)

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

  4. Unknown User (pooja)

    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