【问题标题】:Creating a jenkins job via the api throws an IOException通过 api 创建 jenkins 作业会引发 IOException
【发布时间】:2017-07-03 16:28:32
【问题描述】:

我正在运行 Jenkins 版本。 2.7.1 在 windows 服务器上,我正在尝试通过 api 创建一个新作业。

为简单起见,我已关闭“防止跨站点请求伪造漏洞”并使用 PostMan 提交我的请求。

我发布到http://JENKINSSERVER/createItem?name=apicreateExample,内容类型为application/xml,正文为

<?xml version="1.0" encoding="utf-16"?>
<project>
    <description>BUILD # Telecoms1</description>
    <keepDependencies>true</keepDependencies>
    <properties/>
    <scm class="hudson.scm.NullSCM"/>
    <canRoam>true</canRoam>
    <disabled>true</disabled>
    <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
    <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
    <triggers/>
    <concurrentBuild>false</concurrentBuild>
    <builders/>
    <publishers/>
    <buildWrappers/>
</project>

但是,此调用返回 500 服务器错误,并带有以 java.io.IOException: Unable to delete 'C:\Program Files (x86)\Jenkins\jobs\apicreateExample'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts. 开头的消息

我已经搜索了 stackoverflow 和 google,但没有找到有关此问题的参考。

【问题讨论】:

    标签: jenkins


    【解决方案1】:

    通过将我的 xml 更改为以&lt;?xml version="1.0"?&gt; 开头而不是&lt;?xml version="1.0" encoding="utf-16"?&gt; 来解决这个问题。 (我的 XML 是由 c# 的 XmlWriter 生成的,这是由 WriteStartDocument() 生成的)

    我不知道为什么这会让 Jenkins 绊倒,但希望这会帮助遇到同样问题的其他人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-28
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多