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

Declarative: publishHTML syntax does not work in post block

      Converted this Scripted Pipeline:

      /* Only keep the 10 most recent builds. */
      properties([[$class: 'BuildDiscarderProperty',
                      strategy: [$class: 'LogRotator', numToKeepStr: '10']]])
      
      stage ('Build') {
      
        node {
          // Checkout
          checkout scm
      
          // install required bundles
          sh 'bundle install'
      
          // build and run tests with coverage
          sh 'bundle exec rake build spec'
      
          // Archive the built artifacts
          archive (includes: 'pkg/*.gem')
      
          // publish html
          publishHTML ([
              allowMissing: false,
              alwaysLinkToLastBuild: false,
              keepAll: true,
              reportDir: 'coverage',
              reportFiles: 'index.html',
              reportName: "RCov Report"
            ])
      
        }
      }
      

      To this Declarative:

      pipeline {
          agent any
          options {
              buildDiscarder(logRotator(numToKeepStr:'10'))
          }
          stages {
              stage ('Build') {
                  steps {
                      // install required bundles
                      sh 'bundle install'
      
                      // build and run tests with coverage
                      sh 'bundle exec rake build spec'
                  }
              }
          }
          post {
              success {
                  // Archive the built artifacts
                  archive includes: 'pkg/*.gem'
              }
      
              always {
                  // publish html
                  publishHTML ([
                      allowMissing: false,
                      alwaysLinkToLastBuild: false,
                      keepAll: true,
                      reportDir: 'coverage',
                      reportFiles: 'index.html',
                      reportName: "RCov Report"
                    ])
              }
          }
      }
      

      Fails with this output:

      First time build. Skipping changelog.
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 28: Invalid parameter "allowMissing", did you mean "target"? @ line 28, column 17.
                         allowMissing: false,
                         ^
      
      WorkflowScript: 29: Invalid parameter "alwaysLinkToLastBuild", did you mean "target"? @ line 29, column 17.
                         alwaysLinkToLastBuild: false,
                         ^
      
      WorkflowScript: 30: Invalid parameter "keepAll", did you mean "target"? @ line 30, column 17.
                         keepAll: true,
                         ^
      
      WorkflowScript: 31: Invalid parameter "reportDir", did you mean "target"? @ line 31, column 17.
                         reportDir: 'coverage',
                         ^
      
      WorkflowScript: 32: Invalid parameter "reportFiles", did you mean "target"? @ line 32, column 17.
                         reportFiles: 'index.html',
                         ^
      
      WorkflowScript: 33: Invalid parameter "reportName", did you mean "target"? @ line 33, column 17.
                         reportName: "RCov Report"
                         ^
      
      WorkflowScript: 27: Missing required parameter: "target" @ line 27, column 13.
                     publishHTML ([
                     ^
      
      7 errors
      

      Changed Declarative to this and it succeeds (

      {target:}

      is not needed in Scripted):

      pipeline {
          agent any
          options {
              buildDiscarder(logRotator(numToKeepStr:'10'))
          }
          stages {
              stage ('Build') {
                  steps {
                      // install required bundles
                      sh 'bundle install'
      
                      // build and run tests with coverage
                      sh 'bundle exec rake build spec'
                  }
              }
          }
          post {
              success {
                  // Archive the built artifacts
                  archive includes: 'pkg/*.gem'
              }
      
              always {
                  // publish html
                  publishHTML target:[
                      allowMissing: false,
                      alwaysLinkToLastBuild: false,
                      keepAll: true,
                      reportDir: 'coverage',
                      reportFiles: 'index.html',
                      reportName: "RCov Report"
                    ]
              }
          }
      }
      

          [JENKINS-41456] Declarative: publishHTML syntax does not work in post block

          Liam Newman created issue -
          Liam Newman made changes -
          Description Original: Converted this Scripted Pipeline:
          {code}
          /* Only keep the 10 most recent builds. */
          properties([[$class: 'BuildDiscarderProperty',
                          strategy: [$class: 'LogRotator', numToKeepStr: '10']]])

          stage ('Build') {

            node {
              // Checkout
              checkout scm

              // install required bundles
              sh 'bundle install'

              // build and run tests with coverage
              sh 'bundle exec rake build spec'

              // Archive the built artifacts
              archive (includes: 'pkg/*.gem')

              // publish html
              publishHTML ([
                  allowMissing: false,
                  alwaysLinkToLastBuild: false,
                  keepAll: true,
                  reportDir: 'coverage',
                  reportFiles: 'index.html',
                  reportName: "RCov Report"
                ])

            }
          }
          {code}


          To this Declarative:
          {code}
          pipeline {
              agent any
              options {
                  buildDiscarder(logRotator(numToKeepStr:'10'))
              }
              stages {
                  stage ('Build') {
                      steps {
                          // install required bundles
                          sh 'bundle install'

                          // build and run tests with coverage
                          sh 'bundle exec rake build spec'
                      }
                  }
              }
              post {
                  success {
                      // Archive the built artifacts
                      archive includes: 'pkg/*.gem'
                  }

                  always {
                      // publish html
                      publishHTML ([
                          allowMissing: false,
                          alwaysLinkToLastBuild: false,
                          keepAll: true,
                          reportDir: 'coverage',
                          reportFiles: 'index.html',
                          reportName: "RCov Report"
                        ])
                  }
              }
          }
          {code}

          Fails with this output:
          {code}
          First time build. Skipping changelog.
          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 28: Invalid parameter "allowMissing", did you mean "target"? @ line 28, column 17.
                             allowMissing: false,
                             ^

          WorkflowScript: 29: Invalid parameter "alwaysLinkToLastBuild", did you mean "target"? @ line 29, column 17.
                             alwaysLinkToLastBuild: false,
                             ^

          WorkflowScript: 30: Invalid parameter "keepAll", did you mean "target"? @ line 30, column 17.
                             keepAll: true,
                             ^

          WorkflowScript: 31: Invalid parameter "reportDir", did you mean "target"? @ line 31, column 17.
                             reportDir: 'coverage',
                             ^

          WorkflowScript: 32: Invalid parameter "reportFiles", did you mean "target"? @ line 32, column 17.
                             reportFiles: 'index.html',
                             ^

          WorkflowScript: 33: Invalid parameter "reportName", did you mean "target"? @ line 33, column 17.
                             reportName: "RCov Report"
                             ^

          WorkflowScript: 27: Missing required parameter: "target" @ line 27, column 13.
                         publishHTML ([
                         ^

          7 errors
          {code}

          Changed Declarative to this and it succeeds ({target:} is not needed in Scripted):
          {code}
          pipeline {
              agent any
              options {
                  buildDiscarder(logRotator(numToKeepStr:'10'))
              }
              stages {
                  stage ('Build') {
                      steps {
                          // install required bundles
                          sh 'bundle install'

                          // build and run tests with coverage
                          sh 'bundle exec rake build spec'
                      }
                  }
              }
              post {
                  success {
                      // Archive the built artifacts
                      archive includes: 'pkg/*.gem'
                  }

                  always {
                      // publish html
                      publishHTML ([
                          allowMissing: false,
                          alwaysLinkToLastBuild: false,
                          keepAll: true,
                          reportDir: 'coverage',
                          reportFiles: 'index.html',
                          reportName: "RCov Report"
                        ])
                  }
              }
          }
          {code}
          New: Converted this Scripted Pipeline:
          {code}
          /* Only keep the 10 most recent builds. */
          properties([[$class: 'BuildDiscarderProperty',
                          strategy: [$class: 'LogRotator', numToKeepStr: '10']]])

          stage ('Build') {

            node {
              // Checkout
              checkout scm

              // install required bundles
              sh 'bundle install'

              // build and run tests with coverage
              sh 'bundle exec rake build spec'

              // Archive the built artifacts
              archive (includes: 'pkg/*.gem')

              // publish html
              publishHTML ([
                  allowMissing: false,
                  alwaysLinkToLastBuild: false,
                  keepAll: true,
                  reportDir: 'coverage',
                  reportFiles: 'index.html',
                  reportName: "RCov Report"
                ])

            }
          }
          {code}


          To this Declarative:
          {code}
          pipeline {
              agent any
              options {
                  buildDiscarder(logRotator(numToKeepStr:'10'))
              }
              stages {
                  stage ('Build') {
                      steps {
                          // install required bundles
                          sh 'bundle install'

                          // build and run tests with coverage
                          sh 'bundle exec rake build spec'
                      }
                  }
              }
              post {
                  success {
                      // Archive the built artifacts
                      archive includes: 'pkg/*.gem'
                  }

                  always {
                      // publish html
                      publishHTML ([
                          allowMissing: false,
                          alwaysLinkToLastBuild: false,
                          keepAll: true,
                          reportDir: 'coverage',
                          reportFiles: 'index.html',
                          reportName: "RCov Report"
                        ])
                  }
              }
          }
          {code}

          Fails with this output:
          {code}
          First time build. Skipping changelog.
          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          WorkflowScript: 28: Invalid parameter "allowMissing", did you mean "target"? @ line 28, column 17.
                             allowMissing: false,
                             ^

          WorkflowScript: 29: Invalid parameter "alwaysLinkToLastBuild", did you mean "target"? @ line 29, column 17.
                             alwaysLinkToLastBuild: false,
                             ^

          WorkflowScript: 30: Invalid parameter "keepAll", did you mean "target"? @ line 30, column 17.
                             keepAll: true,
                             ^

          WorkflowScript: 31: Invalid parameter "reportDir", did you mean "target"? @ line 31, column 17.
                             reportDir: 'coverage',
                             ^

          WorkflowScript: 32: Invalid parameter "reportFiles", did you mean "target"? @ line 32, column 17.
                             reportFiles: 'index.html',
                             ^

          WorkflowScript: 33: Invalid parameter "reportName", did you mean "target"? @ line 33, column 17.
                             reportName: "RCov Report"
                             ^

          WorkflowScript: 27: Missing required parameter: "target" @ line 27, column 13.
                         publishHTML ([
                         ^

          7 errors
          {code}

          Changed Declarative to this and it succeeds ({target:} is not needed in Scripted):
          {code}
          pipeline {
              agent any
              options {
                  buildDiscarder(logRotator(numToKeepStr:'10'))
              }
              stages {
                  stage ('Build') {
                      steps {
                          // install required bundles
                          sh 'bundle install'

                          // build and run tests with coverage
                          sh 'bundle exec rake build spec'
                      }
                  }
              }
              post {
                  success {
                      // Archive the built artifacts
                      archive includes: 'pkg/*.gem'
                  }

                  always {
                      // publish html
                      publishHTML target:[
                          allowMissing: false,
                          alwaysLinkToLastBuild: false,
                          keepAll: true,
                          reportDir: 'coverage',
                          reportFiles: 'index.html',
                          reportName: "RCov Report"
                        ]
                  }
              }
          }
          {code}
          Liam Newman made changes -
          Link New: This issue relates to JENKINS-29711 [ JENKINS-29711 ]
          Andrew Bayer made changes -
          Component/s New: htmlpublisher-plugin [ 15681 ]
          Component/s Original: pipeline-model-definition-plugin [ 21706 ]
          Assignee Original: Andrew Bayer [ abayer ] New: mcrooney [ mcrooney ]
          Andrew Bayer made changes -
          Link New: This issue relates to JENKINS-43000 [ JENKINS-43000 ]
          Andrew Bayer made changes -
          Component/s New: pipeline-model-definition-plugin [ 21706 ]
          Component/s Original: htmlpublisher-plugin [ 15681 ]
          Assignee Original: mcrooney [ mcrooney ] New: Andrew Bayer [ abayer ]
          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 ]
          Andrew Bayer made changes -
          Remote Link New: This issue links to "PR #142 (Web Link)" [ 15801 ]
          Andrew Bayer made changes -
          Link New: This issue is duplicated by JENKINS-43000 [ JENKINS-43000 ]
          Andrew Bayer made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]

            abayer Andrew Bayer
            bitwiseman Liam Newman
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: