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

Wrappers provided by plugins not working correctly

      I was going through how to use wrappers in Declarative Pipeline https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Advanced looking how to use the timestamper plugin specifically. Initially I used the wrap() syntax around the classname, which provided this rather helpful error message

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 9: Invalid wrapper type 'wrap'. Valid wrapper types: [ansiColor, catchError, gitlabBuilds, gitlabCommitStatus, lock, node, podTemplate, retry, script, timeout, timestamps, waitUntil, withContext, withEnv, ws] @ line 9, column 9.
      wrap([$class: 'TimestamperBuildWrapper'])
      ^

      So there it was, I just needed to use 'timestamps' and it should work, as declarative pipeline identified it as an available wrapper.

      Unfortunately when trying to do that, I received the following error

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 9: Expected a wrapper @ line 9, column 9.
      timestamps
      ^

      To see if it was an issue with the timestamper plugin, I also tried it with ansiColor, which again showed above as an available wrapper

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 9: Expected a wrapper @ line 9, column 9.
      ansiColor
      ^

      It seems Declarative pipeline is identifying them as available wrappers, but unable to use them as wrappers

          [JENKINS-40721] Wrappers provided by plugins not working correctly

          Tom Larrow created issue -
          Tom Larrow made changes -
          Description Original: I was going through how to use wrappers in Declarative Pipeline https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Advanced looking how to use the timestamper plugin specifically. Initially I used the wrap() syntax around the classname, which provided this rather helpful error message

          {{org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 9: Invalid wrapper type 'wrap'. Valid wrapper types: [ansiColor, catchError, gitlabBuilds, gitlabCommitStatus, lock, node, podTemplate, retry, script, timeout, timestamps, waitUntil, withContext, withEnv, ws] @ line 9, column 9.
                     wrap([$class: 'TimestamperBuildWrapper'])
                     ^}}

          So there it was, I just needed to use 'timestamps' and it should work, as declarative pipeline identified it as an available wrapper.

          Unfortunately when trying to do that, I received the following error
          {{org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 9: Expected a wrapper @ line 9, column 9.
                     timestamps
                     ^
          }}

          To see if it was an issue with the timestamper plugin, I also tried it with ansiColor, which again showed above as an available wrapper

          {{org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 9: Expected a wrapper @ line 9, column 9.
                     ansiColor
                     ^}}

          It seems Declarative pipeline is identifying them as available wrappers, but unable to use them as wrappers
          New: I was going through how to use wrappers in Declarative Pipeline https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Advanced looking how to use the timestamper plugin specifically. Initially I used the wrap() syntax around the classname, which provided this rather helpful error message

          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 9: Invalid wrapper type 'wrap'. Valid wrapper types: [ansiColor, catchError, gitlabBuilds, gitlabCommitStatus, lock, node, podTemplate, retry, script, timeout, timestamps, waitUntil, withContext, withEnv, ws] @ line 9, column 9.
                     wrap([$class: 'TimestamperBuildWrapper'])
                     ^

          So there it was, I just needed to use 'timestamps' and it should work, as declarative pipeline identified it as an available wrapper.

          Unfortunately when trying to do that, I received the following error

          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 9: Expected a wrapper @ line 9, column 9.
                     timestamps
                     ^

          To see if it was an issue with the timestamper plugin, I also tried it with ansiColor, which again showed above as an available wrapper

          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 9: Expected a wrapper @ line 9, column 9.
                     ansiColor
                     ^

          It seems Declarative pipeline is identifying them as available wrappers, but unable to use them as wrappers
          Robby Pocase made changes -
          Assignee Original: Andrew Bayer [ abayer ] New: Robby Pocase [ rpocase ]
          Robby Pocase made changes -
          Assignee Original: Robby Pocase [ rpocase ] New: Andrew Bayer [ abayer ]

          Robby Pocase added a comment -

          As another data point, timestamps does work within a steps block.

          pipeline {
           ...
           stages {
             stage('1') {
               steps {
                 timestamps {
                  ...
                 }
               }
             }
           }
          }
          

          Robby Pocase added a comment - As another data point, timestamps does work within a steps block. pipeline { ... stages { stage('1') { steps { timestamps { ... } } } } }

          Andrew Bayer added a comment -

          So this is a little dumb, but if you do timestamps() rather than just timestamps, it works. I know, I know. I'll see if I can make it smarter.

          Andrew Bayer added a comment - So this is a little dumb, but if you do timestamps() rather than just timestamps , it works. I know, I know. I'll see if I can make it smarter.

          Andrew Bayer added a comment -

          Note to myself - if it's viable to solve this, then we need to do two things:

          • First, get the parser and validator to detect MethodASTMethodCall without args without parentheses in the right cases.
          • Second, get the runtime to probably do a propertyMissing implementation that will return script."barething"() in that case as well.

          Not 100% sure that's possible but I'll see what I can do.

          Andrew Bayer added a comment - Note to myself - if it's viable to solve this, then we need to do two things: First, get the parser and validator to detect MethodASTMethodCall without args without parentheses in the right cases. Second, get the runtime to probably do a propertyMissing implementation that will return script."barething"() in that case as well. Not 100% sure that's possible but I'll see what I can do.

          Andrew Bayer added a comment -

          And the probably easier alternative would be to have better error messages - don't just say "not a wrapper, GTFO" but instead "not a wrapper, here's what wrapper syntax is - foo(), bar("arg"), baz(oneArg: 1, twoArg: 2)" or something like that.

          Andrew Bayer added a comment - And the probably easier alternative would be to have better error messages - don't just say "not a wrapper, GTFO" but instead "not a wrapper, here's what wrapper syntax is - foo(), bar("arg"), baz(oneArg: 1, twoArg: 2)" or something like that.
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

            abayer Andrew Bayer
            tomlarrow Tom Larrow
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: