Create jobs and execute them in jenkins using REST

前端 未结 5 1079
借酒劲吻你
借酒劲吻你 2021-01-30 23:17

I am trying to create a WCF REST client that will communicate to Jenkins and create a job from an XML file and then build the job. My understanding is that you can do that with

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 00:11

    If you want to create a job into a view given the view exists.

    curl -X POST -H "Content-Type:application/xml" -d @build.xml "http://jenkins_host/view/viewName/createItem?name=itemName"
    

    the build.xml filetemplate could be found in the root directory of a job's workspace

    if you want to create a view:

    curl  -X POST -H "Content-Type:application/xml"  -d @view.xml "http://jenkins_host/createView?name=viewName"
    

    the content of the file view.xml could be:

    
    
        viewName
        false
        false
        
        
            
        
        
        
            
            
            
            
            
            
            
        
    
    

    and to check if a view exists:

    curl -X POST -H "Content-Type:application/xml" "http://jenkins_host/checkViewName?value=viewName"
    

    to check if a job exists:

    curl -X POST -H "Content-Type:application/xml" "http://jenkins_host/checkJobName?value=jobName"
    

提交回复
热议问题