我需要你的帮助!
我想知道Hudson如何生成作业的config.xml?
我解释一下:我想在我的应用程序中添加一个类似hudson的构建工具,为此,用户将像Hudson的GUI一样定义一些参数,如jdk的路径,pom.xml存储在哪里, etc ...然后生成此作业的config.xml。
一旦我将获得此作业的config.xml,我将创建并构建它。
我试图搜索Hudson的API,但这都是关于创建一个作业,构建,删除..但没有办法给它参数(个性化它)。这是一个“创建”代码示例:
private void put(HttpClient client, String hudsonBaseURL,String jobName ,File configFile) throws IOException, HttpException {
PostMethod postMethod = new PostMethod(hudsonBaseURL+ "/createItem?name=" + jobName);
postMethod.setRequestHeader("Content-type","application/xml; charset=ISO-8859-1");
postMethod.setRequestBody(new FileInputStream(configFile));
postMethod.setDoAuthentication(true);
try {
int status = client.executeMethod(postMethod);
System.out.println("Projet existe déjà\n"+status + "\n"+ postMethod.getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
}
此方法需要config.xml来创建作业。
我现在正试图在其课程中看到hudson.war的内容,但我不得不说这并不容易。
我希望我很清楚。
任何想法都会受到欢迎。
Nacef。
答案 0 :(得分:7)
我建议使用Hudson's remote API自动创建作业。
看看http://your.hudson.server/api
。 Hudson将返回远程API的HTML文档。在创建作业下,您会看到可以将 config.xml 发布到Hudson URL以创建作业。您应该能够手动创建模板作业,然后将 config.xml 用作自动化系统中的模板。
如this previous answer中所述,可以在HUDSON_HOME/jobs/[name]/config.xml
中找到作业配置。