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

Snippet Generator: produce outdated code for 'properties: Set job properties'

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Jenkins v. 2.161
      Ubuntu Trusty

      I'm looking into parameterizing my pipelines jobs to save on redundancy of the Jenkinsfiles.

      I read a few great resources, e.g:

      and for such a complex job setup - mixture of Job's General and Build Triggers properties (as also advised above) I chose to use snippet code generator for this task.

      But using its generated code fails the pipeline job at its very beginning with this error:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 6: The 'properties' section has been renamed as of version 0.8. Use 'options' instead. @ line 6, column 3.
           properties([
           ^
      

      Searching for the root cause I found following references:

      But no mention about the snippet generator, and why it is still available there to generate incompatible Pipeline code.

      Steps to reproduce

      1. create a new Pipeline job
      2. open snippet generator via Pipeline Syntax link
      3. choose 'properties: Set job properties' as your Sample Step
      4. setup all the parameters you want, hit the 'Generate Pipeline Script'. Mine looked like this:
        properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '2')), parameters([booleanParam(defaultValue: false, description: 'Defines whether to perform a FULL (NIGHTLY) job or just VERIFY (CI) lightweight job.\'', name: 'IS_NIGHTLY'), choice(choices: ['LIN', 'WIN', 'OSX'], description: 'Choose where to run test', name: 'TEST_ENV')]), pipelineTriggers([upstream('PipelineCustomWS, '), pollSCM('''# every 3 minutes
        H/3 * * * *
        ''')])])
      1. past it at the beginning of your pipeline script and run it

      Expected results

      • generated code is valid
      • snipped generator uses the current jenkins instance's the current (latest) implementation of the deployed Jenkins instance SDL API
      • the job runs
      • for manual trigger it provides me with a parameter screen like is possible to see at this video tutorial

      Actual results

      • Jenkins pipeline job fails instantly with following error:
         > git.exe checkout -f 54ee4627061311fe02439120c8749949f78f5662
        Commit message: "Cleared a whitespace char."
        First time build. Skipping changelog.
        org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
        WorkflowScript: 6: The 'properties' section has been renamed as of version 0.8. Use 'options' instead. @ line 6, column 3.
             properties([
             ^
        
        1 error
        
        	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
        	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
        	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
        	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
        	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
        	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
        	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
        	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
        	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
        	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.lambda$doParse$0(CpsGroovyShell.java:135)
        	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:136)
        	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:132)
        	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
        	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:560)
        	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:521)
        	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:320)
        	at hudson.model.ResourceController.execute(ResourceController.java:97)
        	at hudson.model.Executor.run(Executor.java:429)
        Finished: FAILURE
        
      • After replacing 'properties' section with the 'options' as advised in the above error message. It starts complaining about other problems with the options section and found only here how to construct it correctly.

       

      It would be great if the snipper generator could help with such complex setup.

      Thanks

            Unassigned Unassigned
            delphym Daniel Mladek
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: