Newlisp HTTP Basic Authentication, newlisp
HTTP Basic Authentication is very simple, Reference documents: http://zh.wikipedia.org/wiki/HTTP%E5%9F%BA%E6%9C%AC%E8% AE %A4%E8%AF%81
Separate the user name and password with:, and then use base64 encoding. Finally, use the http get method to request the page.
The following code uses newLISP To Call Jenkins's Remote API:
dean@dean-beijing-home:~$ ./http.lsp hello<freeStyleBuild><action><cause><shortDescription>Started by upstream project "detail_summary_pipeline" build number 3</shortDescription><upstreamBuild>3</upstreamBuild><upstreamProject>detail_summary_pipeline</upstreamProject><upstreamUrl>job/detail_summary_pipeline/</upstreamUrl></cause></action><action></action><action><buildsByBranchName><refsremotesorigindevelop><buildNumber>8</buildNumber><marked><SHA1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><branch><SHA1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><name>refs/remotes/origin/develop</name></branch></marked><revision><SHA1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><branch><SHA1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><name>refs/remotes/origin/develop</name></branch></revision></refsremotesorigindevelop></buildsByBranchName><lastBuiltRevision><SHA1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><branch><SHA1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><name>refs/remotes/origin/develop</name></branch></lastBuiltRevision><remoteUrl>git@gitlab.bigdata.leshiren.com:datawarehouse/log_aggregation.git</remoteUrl><scmName></scmName></action><action></action><action></action><action></action><building>false</building><duration>105297</duration><estimatedDuration>95546</estimatedDuration><fullDisplayName>sum_user_query_day_cloud #8</fullDisplayName><id>2014-10-02_11-01-53</id><keepLog>false</keepLog><number>8</number><result>SUCCESS</result><timestamp>1412218913296</timestamp><url>http://10.100.86.22:8080/job/sum_user_query_day_cloud/8/</url><builtOn>slave25</builtOn><changeSet><kind>git</kind></changeSet></freeStyleBuild>
The source code of http. lsp is as follows:
#!/usr/bin/newlisp(println "hello")(set 'user-pass "user:pwd")(set 'auth (append "Authorization: Basic " (base64-enc user-pass) "\r\n"))(set 'xml (get-url "http://your_jenkins/job/your_job/lastBuild/api/xml" 5000 auth))(println xml)(exit)
Note that the get-url function is powerful. Here, 5000 refers to the timeout time. auth refers to sending the encoded user name and password in the header.
What is http basic authentication?
Reference: smalltalllong.iteye.com/blog/912046
It's quite clear.
Java basic Authentication
If you are interested in JAVA, you can watch crazy JAVA videos and books to study and authenticate.