jenkins 读取json文件_jenkins:实现Jenkinsfile与Json的转换

本文介绍了如何实现Jenkinsfile与Json之间的转换,包括使用现有Jenkins插件的步骤和方法,以及解析原生Jenkinsfile文件的项目介绍。详细讲解了插件打包、API使用、转换操作和解析jenkinsfile的挑战。
摘要由CSDN通过智能技术生成

实现Jenkinsfile与Json的转换

最近在作个需求,须要支持Jenkinsfile和json的转换。html

方法1:使用现有的jenkins插件

参考的是这篇文章。下面介绍一下将插件打包成镜像的步骤:git

本地安装jdk和maven,jdk建议采用的版本为8(该工程会依赖一个名为tools.jar的包,jdk 9以后移除了该包)github

若是本地没有找到tools.jar,能够下载一个1.8版本的jdk,而后在pom.xml中增长以下依赖docker

jdk.tools

jdk.tools

1.8.0

system

/root/jdk1.8.0_271/lib/tools.jar

在/root/.m2/目录下建立settings.xml,内容来自Jenkins官方:maven

org.jenkins-ci.tools

jenkins

true

repo.jenkins-ci.org

https://repo.jenkins-ci.org/public/

repo.jenkins-ci.org

https://repo.jenkins-ci.org/public/

repo.jenkins-ci.org

https://repo.jenkins-ci.org/public/

m.g.o-public

执行 mvn install进行编译编辑器

因为主要用到的是Jenkinsfile和json之间的转换关系,所以主要用的是以下两个REST API:ui

Conversion to JSON representation from Jenkinsfilethis

URL: JENKINS_URL/pipeline-model-converter/toJson

Parameters: jenkinsfile - the Jenkinsfile contents

Info: Takes a Jenkinsfile and converts it to the JSON representation for its pipeline step.

Returns: JSON with a result field that will either be success or failure. If success, the JSON representation will be in the json field. If failure, there'll be an additional array in the errors field of the error messages encountered.

Conversion to Jenkinsfile from JSON representationatom

URL: JENKINS_URL/pipeline-model-converter/toJenkinsfile

P

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值