从另一个 Jenkinsfile 调用远程 jenkins 文件 [英] Invoke a remote jenkins file from another Jenkinsfile

查看:85
本文介绍了从另一个 Jenkinsfile 调用远程 jenkins 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的组织设计一个 Jenkins CICD 管道,我有以下问题.

I am designing a Jenkins CICD pipeline at my organization and I have a following question.

我来自一个为多个开发团队控制 Jenkins 管道的 devops 团队.我基本上想编写一个可以由多个团队运行的具有多个阶段的 Jenkins 文件.我知道这个 Jenkins 文件可以签入到每个团队的 Gitrepo 中,并且只要对代码仓库进行更改,它就可以调用完整的管道.

I am from a devops team that controls the Jenkins pipeline for multiple development teams. I basically want to write a Jenkins file with multiple stages that can be run by multiple teams. I understand that this Jenkins file can be checked into the Gitrepo of each team and it can invoke the complete pipeline as soon as the changes are done to the code repo.

为了确保这个 JenkinsFile 是可维护的,并且对于这个 Jenkins 文件的任何未来更改,我不必要求所有各个团队在他们的 Gitrepo 中更新这个文件,我想把这个文件放在一个受控制的中央 Gitrepo由我的团队.

To make sure that this JenkinsFile is maintainable and for any future changes to this Jenkins file I dont have to ask all the various teams to update this file in their Gitrepo , I want to place this file at a central Gitrepo that is controlled by my team.

是否可以从不同的 Gitrepos 调用这个 Jenkins 文件?有什么例子吗?

Is it possible to invoke this Jenkins file from different Gitrepos? Any examples?

推荐答案

我可以这样做:

我的 Base repo 像这样简单地称为远程 repo:

My Base repo simply called a remote repo like this :

#!/usr/bin/env groovy
def jenkinsFile
stage('Loading Jenkins file') {
  jenkinsFile = fileLoader.fromGit('testjenkinsstuff/cicd/testMyPipeline', 'https://github.myorg.com/user/testjenkinsstuff.git', 'master', null, '')
}

jenkinsFile.start()

这篇关于从另一个 Jenkinsfile 调用远程 jenkins 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆