Jenkins 与 intellij 共享库 [英] Jenkins shared library with intellij

查看:15
本文介绍了Jenkins 与 intellij 共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始实现 Jenkins 共享库并尝试使用 intellij 作为我的 ide 编写我的 jenkinsfile.

I started implement Jenkins shared libraries and trying to write my jenkinsfile with intellij as my ide.

我如何从共享 lib 存储库中获取函数到包含 jenkins 文件的另一个存储库.

How do I get functions from the shared lib repository to the other repository which holds the jenkins file inside it.

只是为了澄清从 jenkins 运行时事情对我有用,但我需要一种简单的方法来编写我的 jenkins 文件,并使用来自 shared-lib 存储库的函数.

Just to clarify things are working for me when running from jenkins but I need an easy way to write my jenkins file with the usage of functions from the shared-lib repo.

推荐答案

你可以尝试在你的IDE中使用Jenkins提供的IntelliJ IDEA GDSL文件.

You can try using the IntelliJ IDEA GDSL file provided by Jenkins in your IDE.

http://<JENKINS>/job/<PIPELINE_JOB>/pipeline-syntax/gdsl 下载内容到 pipline.gdsl 文件并添加将此文件添加到您的 IntelliJ Jenkins Pipeline 项目的源文件夹中.(您可能还想将该文件添加到您的 SCM 忽略列表中.)

Download the content from http://<JENKINS>/job/<PIPELINE_JOB>/pipeline-syntax/gdsl to a pipline.gdsl file and add this file to your IntelliJ Jenkins Pipeline project's source folder. (You may also want to add that file to your SCMs ignore-list.)

自动补全beforeafter添加GDSL文件:

Autocompletion before and after adding GDSL file:

Jenkins UI 上,您可以在管道语法 > IntelliJ IDEA GDSL"下的管道项目中找到该 GDSL 文件.

On the Jenkins UI you find that GDSL file in your pipeline project under "Pipeline Syntax > IntelliJ IDEA GDSL".

但是,我发现此解决方案的一些注意事项需要我手动编辑 pipeline.gdsl 文件,但这可能与我的 Jenkins 安装不是最新 (?) 有关:

However, I found some caveats with this solution that required me to manually edit the pipeline.gdsl file, but that could be related to my not up-to-date Jenkins installation (?):

  • 在 GDSL 文件中考虑了自定义全局变量(来自 /var 文件夹),但在该变量上定义的方法不考虑.
  • parallel 步骤未正确导出,原因是 ParallelStep 类出现错误(?)
  • custom global variables (from the /var folder) are considered in the GDSL file, but methods defined on that variable are not.
  • the parallel step was not exported properly due to an error(?) on the ParallelStep class

(知识来源:Veaceslav Gaidarji 的博客.)

这篇关于Jenkins 与 intellij 共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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