Can I load a declarative Jenkinsfile via a shared library?

已查看 69 次
跳至第一个未读帖子

Idan Adar

未读,
2018年1月10日 13:32:532018/1/10
收件人 Jenkins Users
Is the following feasible?

1. Setup a Shared Library in the Jenkins settings
2. In every repository requiring the Jenkinsfile (it is the same one used in multiple repos...), use the following in the Jenkinsfile of the repository instead:


@Library("my-shared-library") _
    standardPipeline
{
       
// properties passed to the shared library
   
}

3. In the Shared Library, use this: 

def call(body) {
 
def config = [:]
  body
.resolveStrategy = Closure.DELEGATE_FIRST
  body
.delegate = config
  body
()

  pipeline
{
     
// the declarative pipeline as-is as it was previously used in a Jenkinsfile in a repository
 
}
}

Daniel Butler

未读,
2018年1月10日 13:46:562018/1/10
收件人 jenkins...@googlegroups.com
I believe this was added a month or two ago.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c878f51d-8097-43fb-a0f5-a95b471f0184%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Idan Adar

未读,
2018年1月10日 13:49:212018/1/10
收件人 jenkins...@googlegroups.com
Any prerequisites?

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/EG1BLWQq1Mo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO37hbi18NX6yiGCj8_7AApgY0UTt4Q7_eXJcH26%3DQx9NtWBug%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Idan Adar

Idan Adar

未读,
2018年1月11日 02:41:502018/1/11
收件人 Jenkins Users

Joe Cavanaugh

未读,
2018年1月11日 10:30:012018/1/11
收件人 Jenkins Users
You have to have the declarative pipeline 1.2 or higher to do this. I am having issues putting the "powershell" keyword in the library... otherwise it seems to work. 
回复全部
回复作者
转发
0 个新帖子