Hudson如何生成作业config.xml?

b-l*_*eve 1 jobs hudson

我需要你的帮助 !

我想知道Hudson如何生成作业的config.xml?

我解释一下:我想在我的应用程序中添加一个类似hudson的构建工具,为此,用户将像Hudson的GUI一样定义一些参数,如jdk的路径,存储pom.xml的位置等等.然后生成此作业的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();
    }
}
Run Code Online (Sandbox Code Playgroud)

此方法需要config.xml来创建作业.

我现在正试图在其课程中看到hudson.war的内容,但我不得不说这并不容易.

我希望我很清楚.

任何想法都会受到欢迎.

Nacef.

Dav*_*her 7

我建议使用Hudson的远程API来自动创建作业.

看看http://your.hudson.server/api.Hudson将返回远程API的HTML文档.在Create Job下,您将看到可以将config.xml发送到Hudson URL以创建作业.您应该能够手动创建模板作业,然后将该config.xml用作自动化系统中的模板.

如上一个答案中所述,可以在中找到作业配置HUDSON_HOME/jobs/[name]/config.xml.