如何在另一个Jenkins共享库中调用函数 [英] How to call functions in one Jenkins Shared Library from another

查看:611
本文介绍了如何在另一个Jenkins共享库中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个独立的库(库A和库B),我已经在jenkins配置中定义了它们,因此可以从管道中调用它们.

I have two separate libraries (Library A and Library B), I have defined them on the jenkins configuration so they can be both called from the pipeline.

我想从库A中调用库B中定义的一些函数/方法.

From Library A I would like to call some functions/methods that are defined in Library B.

我的逻辑告诉我,在可以访问任何库B方法之前,我需要导入并可能在库A中创建库B的实例.但是我没有成功.我不是Java方面的专家,但是非常感谢任何指导.

My logic tells me that I need to import and probably create an instance of Library B inside Library A before I can have access to any of Library B methods. But I have not been successful. I am no expert in Java, however any guidance is greatly appreciated.

推荐答案

在Jenkinsfile中:

In Jenkinsfile:

@Library(['libA', 'libB']) _

,您可以在它们之间进行呼叫:

and you can call between them:

import org.myorg.PruebaA / import org.myorg.PruebaB

这篇关于如何在另一个Jenkins共享库中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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