Based on the links that you provided, I've now tried the following both of
which seem to work so hopefully you might be able to extract the relevant
bits out and apply to your codebase (note that I'm by far any expert on
pipelines - just learning them myself really!)

Attempt 1 - using a custom step
---
Pipeline
@Library('Test')
import Utilities
runFunctionalTests()

var/runFunctionalTests.groovy
def call() {
  node {
    steps.publishHTML([allowMissing: false, alwaysLinkToLastBuild: false,
keepAll: false, reportDir: 'target/allure-reports', reportFiles:
'index.html', reportName: 'Allure Report', reportTitles: ''])
  }
}
---

Attempt 2 - using a Groovy method
---
Pipeline
@Library('Test')
import Utilities
def utils = new Utilities(steps)
node {
    utils.doSomething()
}

src/Utilities.groovy
class Utilities implements Serializable {
  def steps
  Utilities(steps) {this.steps = steps}
  def doSomething() {
    steps.publishHTML([allowMissing: false, alwaysLinkToLastBuild: false,
keepAll: false, reportDir: 'target/allure-reports', reportFiles:
'index.html', reportName: 'Allure Report', reportTitles: ''])
  }
}
---

Hopefully that is of some use to you!

Cheers
Richard.

On Sat, 9 Sep 2017 at 16:37 Ann B <annc...@gmail.com> wrote:

> Accessing steps section -
> https://jenkins.io/doc/book/pipeline/shared-libraries/#accessing-steps is
> actually a better section to look at to understand our use case.
>
> Specifically this section:
>
> "This approach has limitations; for example, it prevents the declaration
> of a superclass.
>
> Alternately, a set of steps can be passed explicitly to a library class,
> in a constructor, or just one method"
>
> I'm passing the steps instance to a method in a library class.
>
>
> On Friday, September 8, 2017 at 9:30:26 PM UTC-7, Ann B wrote:
>>
>> Hi Richard-
>>
>> Thank you for your work with this plugin!
>>
>> Yes, publishHTML([allowMissing: false, alwaysLinkToLastBuild: false,
>> keepAll: false, reportDir: 'results', reportFiles: 'report.html',
>> reportName: 'HTML Report', reportTitles: '']) works find within the
>> context of a shared library script in src directory.
>>
>> My issue is that I've created a custom step (global variable) within the
>> var directory of my shared library.  The way I understand it, you have to
>> access the DSL via the steps object.  This page has more information -
>> https://support.cloudbees.com/hc/en-us/articles/217736618-How-do-I-access-Pipeline-DSLs-from-inside-a-Groovy-class-
>> as well as this page -
>> https://jenkins.io/doc/book/pipeline/shared-libraries/#defining-global-variables
>>
>> If I code:
>> publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll:
>> false, reportDir: 'results', reportFiles: 'report.html', reportName: 'HTML
>> Report', reportTitles: '']) in my method in my class in my var
>> directory, then I get the following error:
>> *hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No
>> signature of method: org.magento.ci.tests.Functional.publishHTML() is
>> applicable for argument types: (java.util.LinkedHashMap) values:
>> [[allowMissing:false, alwaysLinkToLastBuild:false, keepAll:false, ...]]*
>>
>> Thanks again,
>>
>> Ann
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/261699f8-b0c8-4926-8de7-5db65461df55%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/261699f8-b0c8-4926-8de7-5db65461df55%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAMui946XBQ8iE%3DEKhWL%3DMsZ4TthZ0ocPYMT-Rp2-UtwttZJgvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to