Jenkins打包android項目構建成功后發送http-post請求


這篇文章主要記錄Jenkins自動化打包android項目后使用http-request插件發送post請求的記錄

1.安裝http-request插件,步驟如下:
  插件下載地址:http://updates.jenkins-ci.org/download/plugins/
  搜索選擇http_request下載到本地,然后按照下面的截圖上傳並安裝插件
      
  系統管理-->插件管理-->選擇高級-->上傳插件
  上傳成功后最好重啟一下Jenkins,瀏覽器輸入:http://xx.xx.xx.xx:8080/restart 回車確認即可重啟。到這插件安裝完成。接下來就是創建pipeline的步驟了。
2.編寫pipeline流水線腳本  
     
   新建任務-->輸入名稱-->選擇流水線-->確定

   Jenkins-->我的視圖-->項目列表,即可看到所有項目,包括剛才創建的pipeline流水線.
   選擇剛才創建的pipeline-->點擊配置進入配置頁面,下面就是在配置頁面進行操作了。
      

def response = httpRequest contentType: 'APPLICATION_JSON',
        httpMode: "POST",
        customHeaders: [
          [name: "token", value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9uxHjaqt-hI"]
        ],
        url: "https://xxx.com/message?is_room=true&type=1&content=Android最新安裝包:http://xx.xx.xx.xx:8080/job/Android/lastSuccessfulBuild/artifact/app/build/outputs/apk/"
println response.status
println response.content

//具體httpRequest參數請參考:https://www.jenkins.io/doc/pipeline/steps/http_request/#httprequest-perform-an-http-request-and-return-a-response-object

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM