简体   繁体   English

詹金斯参数化构建与关系工件

[英]jenkins parameterized build with nexus artifacts

i am working on Jenkins to create a continuous integration. 我正在Jenkins上进行持续集成。 i want to create a job with parameters which will have a drop down list of artifacts that are stored in nexus and a drop down list of environment that we want those artifacts to be deployed to (web sphere). 我想创建一个带有参数的作业,该参数将具有存储在关系中的工件的下拉列表以及我们要将这些工件部署到(网络领域)的环境的下拉列表。 i am new to Jenkins and would like to get any help that will help me start the job. 我是Jenkins的新手,并希望获得任何帮助我开始工作的帮助。

You will need Extended Choice Parameter plugin to achieve your goal. 您将需要扩展选择参数插件来实现您的目标。 You will have to store the list of artifacts fetched from Nexus in a file. 您必须将从Nexus提取的工件列表存储在文件中。 Same goes for the list of environments. 环境列表也是如此。 These files will then be picked up by the above plugin using the method described in this link. 然后,上述插件将使用链接中描述的方法来提取这些文件。 Property File option is what you need to use in the given plugin. Property File选项是您需要在给定插件中使用的选项。

You can also use Dynamic choice parameter , 您也可以使用动态选择参数

Then write a groovy script that will take the meatdata out from Nexus, 然后编写一个Groovy脚本,将肉数据从Nexus中取出,

For me it's working just great. 对我来说,它工作得很好。

import groovy.xml.*;
import groovy.util.*;

myUrl = "http://NexusServer.fo.net:8081/nexus/service/local/repositories/repo-name/content/groupID/maven-metadata.xml"


def data = new URL(myUrl).getText()

def dataObj = new XmlParser().parseText(data)
def versions=[]
for (v in dataObj.versioning[0].versions[0].version){
          versions.add(v.value()[0])
}
versions.sort(false).reverse()

This is how it looks at the end: 这是最后的样子:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM