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

4 views
Skip to first unread message

bitwiseman@gmail.com (JIRA)

unread,
Jan 25, 2017, 4:44:01 PM1/25/17
to jenkinsc...@googlegroups.com
Liam Newman created an issue
 
Jenkins / Bug JENKINS-41456
Declarative: publishHTML syntax does not work in post block
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Jan/25 9:43 PM
Priority: Minor Minor
Reporter: Liam Newman

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 ([
                allowMissing: false,
                alwaysLinkToLastBuild: false,
                keepAll: true,
                reportDir: 'coverage',
                reportFiles: 'index.html',
                reportName: "RCov Report"
              ])
        }
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Jan 25, 2017, 7:24:01 PM1/25/17
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-41456
 
Re: Declarative: publishHTML syntax does not work in post block

Your final example looks the same as the previous one?

bitwiseman@gmail.com (JIRA)

unread,
Jan 25, 2017, 11:34:01 PM1/25/17
to jenkinsc...@googlegroups.com
Liam Newman updated an issue
 
Change By: Liam Newman
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}
{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}

bitwiseman@gmail.com (JIRA)

unread,
Jan 25, 2017, 11:35:01 PM1/25/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Jan 26, 2017, 11:26:01 AM1/26/17
to jenkinsc...@googlegroups.com

So this is a combination of magic and validation not working ideally. I'm not honestly entirely sure how this works in Scripted Pipeline, but the map of arguments gets automatically transformed into an HtmlPublisherTarget instance, which is what publishHTML expects as an argument. Declarative's validation doesn't have that ability to say "Oh, you've got a Map passed in - let's see if that can become the class the step expects as its argument" - I'll see if that's something we can add, but no promises.

bitwiseman@gmail.com (JIRA)

unread,
Jan 31, 2017, 3:53:01 PM1/31/17
to jenkinsc...@googlegroups.com

Andrew Bayer It is somewhat important that what worked in Scripted continues to work in Declarative.

It looks like you fixed this before for JENKINS-29711 in Scripted.

andrew.bayer@gmail.com (JIRA)

unread,
Mar 21, 2017, 7:12:01 PM3/21/17
to jenkinsc...@googlegroups.com
Andrew Bayer assigned an issue to mcrooney
 

Moving this to htmlpublisher-plugin, since the actual problem is its @DataBoundConstructor.

Change By: Andrew Bayer
Component/s: htmlpublisher-plugin
Component/s: pipeline-model-definition-plugin
Assignee: Andrew Bayer mcrooney
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Mar 21, 2017, 9:58:01 PM3/21/17
to jenkinsc...@googlegroups.com
Andrew Bayer assigned an issue to Andrew Bayer
 

Changed my mind! This can and should be addressed in Declarative - we should look to see if there's a sole required parameter that takes a map, and if so, translate accordingly.

Change By: Andrew Bayer
Component/s: pipeline-model-definition-plugin
Component/s: htmlpublisher-plugin
Assignee: mcrooney Andrew Bayer

andrew.bayer@gmail.com (JIRA)

unread,
Mar 21, 2017, 10:02:02 PM3/21/17
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-41456
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Mar 21, 2017, 10:02:02 PM3/21/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Mar 21, 2017, 10:02:02 PM3/21/17
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Mar 27, 2017, 12:17:03 PM3/27/17
to jenkinsc...@googlegroups.com
SCM/JIRA link daemon commented on Bug JENKINS-41456
 
Re: Declarative: publishHTML syntax does not work in post block

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTArgumentList.java
pipeline-model-definition/pom.xml
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
pipeline-model-definition/src/test/resources/htmlPublisher.groovy
pom.xml
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/3020057c7dabad0af4b5f5f34f4102cee274a894
Log:
[FIXED JENKINS-41456] Properly validate publishHTML

Specifically, when we see that there's a sole required parameter, the
only provided argument by the user is a map, at least one of those map
keys doesn't have a corresponding parameter in the describable, and
the sole required parameter's type is a describable itself, validate
the argument map against that parameter type describable instead of
against the parent describable. So for publishHTML, that means
realizing `target` is an `HtmlPublisherTarget` and validating the map
against that.

andrew.bayer@gmail.com (JIRA)

unread,
Mar 27, 2017, 12:17:03 PM3/27/17
to jenkinsc...@googlegroups.com

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:27 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages