Ann*_*nna 1 rest jenkins jenkins-job-builder
我无法远程创建Job(REST API + Postman),我尝试
开机自检:
http://localhost:8080/createItem?name=NEWJOB
要么
http://localhost:8080/job/NEWJOB/build
并且总是有403错误(GET方法起作用)。
在这里,我看到我需要为POST创建config.xml:
https://issues.jenkins-ci.org/browse/JENKINS-9410?focusedCommentId=204821&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-204821
我不明白如何创建此配置?我需要这个配置吗?如何远程创建jenkins Job?
It takes me several steps:
1) GET
http://localhost:8080/crumbIssuer/api/json
Run Code Online (Sandbox Code Playgroud)
+header Authorization ..................... Basic YWRtaW46YWRtaW4=
Value of Authorization field was created when I put in login and password(admin,admin in my case).
After this query I saw next:
{
"_class": "hudson.security.csrf.DefaultCrumbIssuer",
"crumb": "2ad62df85d23d4c65a25c0b33fb0ef61",
"crumbRequestField": "Jenkins-Crumb"
}
Run Code Online (Sandbox Code Playgroud)
2)Next step -> create config.xml
I just take it from another jenkins job (named test) manually when I :
GET http://localhost:8080/job/test/config.xml
+header header Authorization .............. Basic YWRtaW46YWRtaW4=
3)Create job:
POST http://10.14.48.107:8080/createItem?name=NEWJOBNAME
+header Authorization ........ Basic YWRtaW46YWRtaW4=
+header Content-Type ........... text/xml
+header Jenkins-Crumb ......... 2ad62df85d23d4c65a25c0b33fb0ef61
I take this header name and value from 1st query crumb
+Body->raw->
<project>
<actions/>
<description/>
<keepDependencies>false</keepDependencies>
<properties>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.29.0">
<displayName/>
</com.coravy.hudson.plugins.github.GithubProjectProperty>
</properties>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers/>
<buildWrappers/>
</project>
Run Code Online (Sandbox Code Playgroud)
After this step I have had nothing as answer, but job was created remotely!
归档时间: |
|
查看次数: |
3286 次 |
最近记录: |