Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38789

Provide pipeline example that enables timestamper if is available

    Details

    • Similar Issues:

      Description

      While this may sound like an unimportant feature request I think it would really be nice if we could have some jenkins pipeline code that is loading the timestamper if is available and if not just running the same block without it.

      Can we have such an example?

      PS. I was a real pleasure to see the new DLS syntax from version 1.8. Thanks.

        Attachments

          Activity

          Hide
          stevengbrown Steven G Brown added a comment -

          Glad you like the new syntax. I don't know off the top of my head how your example code would look, but let me know if you work it out!

          Show
          stevengbrown Steven G Brown added a comment - Glad you like the new syntax. I don't know off the top of my head how your example code would look, but let me know if you work it out!
          Hide
          quas Jakub Pawlinski added a comment -

          So we don't have an example still?

          Show
          quas Jakub Pawlinski added a comment - So we don't have an example still?
          Hide
          stevengbrown Steven G Brown added a comment -

          No, I haven't seen any examples. I'm not even sure if this is something pipeline supports?

          Show
          stevengbrown Steven G Brown added a comment - No, I haven't seen any examples. I'm not even sure if this is something pipeline supports?
          Hide
          ssbarnea Sorin Sbarnea added a comment -

          I am really interested about this subject because all these wrappers like: timestamper, ansicoloring or timeout ones do add extra complexity (blocks) to pipeline scripts, making them much harder to write in a clean way.

          Also they have the bad habit of not downgrading gracefully if one of these optional plugins are not available.

          If we would be able to use some kind of annotation mechanism to enable them when they are available it would much easier for everyone.

          Show
          ssbarnea Sorin Sbarnea added a comment - I am really interested about this subject because all these wrappers like: timestamper, ansicoloring or timeout ones do add extra complexity (blocks) to pipeline scripts, making them much harder to write in a clean way. Also they have the bad habit of not downgrading gracefully if one of these optional plugins are not available. If we would be able to use some kind of annotation mechanism to enable them when they are available it would much easier for everyone.
          Hide
          quas Jakub Pawlinski added a comment - - edited

          based on https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Syntax-Reference 

          you just have to set in pipeline:
           

          options { timestamps() }

           and yes, it works

          Show
          quas Jakub Pawlinski added a comment - - edited based on  https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Syntax-Reference   you just have to set in pipeline:   options { timestamps() }  and yes, it works
          Hide
          ssbarnea Sorin Sbarnea added a comment -

          Thanks, this documents very well the new declarative-pipeline syntax (the... 5th, of 6th way of writing jobs in jenkins is i count well.)

          What I was looking for was a way to enable the timestamps (or other wrappers in non-scripted pilelines in a way that degrade gracefully).

          Here is the deal: most wrappers if (not even all), do add some extra functionality without which the job would probably still be able to run. 

          What would be very powerful would be to have some kind of way to do enable the wrapper if installed or ignore that.

           

          Show
          ssbarnea Sorin Sbarnea added a comment - Thanks, this documents very well the new declarative-pipeline syntax (the... 5th, of 6th way of writing jobs in jenkins is i count well.) What I was looking for was a way to enable the timestamps (or other wrappers in non-scripted pilelines in a way that degrade gracefully). Here is the deal: most wrappers if (not even all), do add some extra functionality without which the job would probably still be able to run.  What would be very powerful would be to have some kind of way to do enable the wrapper if installed or ignore that.  
          Hide
          jbochenski Jakub Bochenski added a comment -

          I also think it's a pain to repeat all those options. Its a textbook example of boilerplate.

          In regular scripted pipeline you can at least use the code-sharing to have a common wrapper (and use reflection to enable things if available), but there seems to be no solution for declarative syntax

          Show
          jbochenski Jakub Bochenski added a comment - I also think it's a pain to repeat all those options. Its a textbook example of boilerplate. In regular scripted pipeline you can at least use the code-sharing to have a common wrapper (and use reflection to enable things if available), but there seems to be no solution for declarative syntax
          Hide
          dbsanfte David Sanftenberg added a comment -

          The timestamps() option does not work in declarative pipeline:

          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 20: Invalid option type "timestamps". Valid option types: [ansiColor, authorizationMatrix, buildDiscarder, catchError, checkoutToSubdirectory, copyArtifactPermission, disableConcurrentBuilds, disableResume, durabilityHint, lock, newContainerPerStage, office365ConnectorWebhooks, overrideIndexTriggers, parallelsAlwaysFailFast, preserveStashes, quietPeriod, rateLimitBuilds, retry, script, skipDefaultCheckout, skipStagesAfterUnstable, task, timeout, waitUntil, withContext, withCredentials, withEnv, ws] @ line 20, column 2.

          timestamps ()

          ^1 error

          Show
          dbsanfte David Sanftenberg added a comment - The timestamps() option does not work in declarative pipeline: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 20: Invalid option type "timestamps". Valid option types: [ansiColor, authorizationMatrix, buildDiscarder, catchError, checkoutToSubdirectory, copyArtifactPermission, disableConcurrentBuilds, disableResume, durabilityHint, lock, newContainerPerStage, office365ConnectorWebhooks, overrideIndexTriggers, parallelsAlwaysFailFast, preserveStashes, quietPeriod, rateLimitBuilds, retry, script, skipDefaultCheckout, skipStagesAfterUnstable, task, timeout, waitUntil, withContext, withCredentials, withEnv, ws] @ line 20, column 2. timestamps () ^ 1 error

            People

            • Assignee:
              Unassigned
              Reporter:
              ssbarnea Sorin Sbarnea
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: