Is is possible to define methods in a declarative pipeline?

278 views
Skip to first unread message

Dallas Clement

unread,
Aug 16, 2017, 12:19:40 PM8/16/17
to Jenkins Users
I would like to be able to define some groovy methods in my declarative Jenkinsfile and call as needed from a script {} section.  For example I would like to define some methods that extract git commit information from the jenkins API and use when notifying concerning build status from one of the pipeline post conditions.  Is it possible to define methods in a declarative pipeline? 

Dallas Clement

unread,
Aug 16, 2017, 1:40:04 PM8/16/17
to Jenkins Users
I'm answering my own question here.  It looks like this is indeed possible.  I added some method definitions at the end of my Jenkinsfile following the pipeline definition.  I was able to call the methods from a script {} embedded in stages and post sections.
Reply all
Reply to author
Forward
0 new messages