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

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

问题描述

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

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

我来自一个devops团队,该团队控制着多个开发团队的Jenkins渠道.我基本上想编写一个可以由多个团队运行的具有多个阶段的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?

推荐答案

这是我的方法:

我的基本存储库简称为远程存储库,如下所示:

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天全站免登陆