如何从Jenkins获取数据到Confluence(云)

我试图从jenkins写入融合,但我有一些问题要么得到一个特定的解决scheme工作(configuration?插件错误?),或有问题find适当的信息来实现。

样品最终结果:

  • Jenkins Job查询Cloudflare API并生成一个DNS条目表以进入合stream。
  • Confluence跟踪更改并提供历史logging(cloudflare似乎没有任何审计function

潜在的解决scheme1 – Confluence Publisher插件

  • 我已经尝试过这个插件,但它似乎是非常古老的(4年不更新,插件的开发人员可能3年没有显示任何明显的活动)。
  • 我们使用Atlassians Cloud Confluence,但尝试执行全局configuration并testinglogin时,使用我自己的凭据进行testing时会触发通用的“用户名/密码不被接受”错误。
  • 经过多次尝试之后,邮件已经更改为太多次尝试,并且所列出的步骤不会更改错误消息(重新login到标准Web UI)

(下面的代码块不会显示,除非上面的列表和代码块之间的东西… serverfault格式错误?)

AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: com.atlassian.confluence.rpc.AuthenticationFailedException: Attempt to log in user '[email protected]' failed. The maximum number of failed login attempts has been reached. Please log into the web application through the web interface to reset the number of failed login attempts. faultActor: faultNode: faultDetail: {}com.atlassian.confluence.rpc.AuthenticationFailedException:null {http://xml.apache.org/axis/}hostname:redacted.atlassian.net com.atlassian.confluence.rpc.AuthenticationFailedException: Attempt to log in user '[email protected]' failed. The maximum number of failed login attempts has been reached. Please log into the web application through the web interface to reset the number of failed login attempts. 

潜在的解决scheme2 – 将Jenkins发布到任意主机,并从汇合中使用iframemacros

  • 编辑 – 我可能实际上能够使这个解决scheme的工作。 我可能是一个白痴思考这里的东西会构成一个挑战。
  • https://ip-ranges.amazonaws.com/ip-ranges.json
  • 最后,我仍然需要破解一个跟踪更改的解决scheme(push to git?)

潜在的解决scheme3 – 我发现我可以直接使用REST API。 我们面临的挑战是确保curl调用是完全格式化的(json + html内容)

潜在的解决schemeN – 我错过了什么?

我结束了去REST API路线,使用jqparsing传入的JSON

首先获取页面ID:

 pageID=$(curl -u $Confluence_UserID:$Confluence_Password -X GET \ "https://redacted.atlassian.net/wiki/rest/api/content?title=$PageTitle&spaceKey=$Space" \ | jq -r .results[].id \ ) 

然后获取版本(版本号必须提供并增加或更新呼叫失败!)

 pageVersion=$(curl -u $Confluence_UserID:$Confluence_Password \ "https://redacted.atlassian.net/wiki/rest/api/content/$pageID?expand=version" \ | jq .version.number \ ) ((pageVersion++)) 

在jenkins工作之前,它将汇合页面的HTML生成到工作区中的一个文件中。 加载以下使用

 htmlOutput=$(<myHTMLSnippet.txt) 

最后一部分,发送页面更新

 curl -u $Confluence_UserID:$Confluence_Password \ -X PUT -H 'Content-Type: application/json' \ https://redacted.atlassian.net/wiki/rest/api/content/$pageID \ --data @- <<END; { "id": "$pageID", "type": "page", "title": "$PageTitle", "space": { "key": "$Space" }, "body": { "storage": { "value": "$htmlOutput", "representation": "storage" } }, "version": { "number": $pageVersion, "minorEdit": true } } END