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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.