1. 程式人生 > 其它 >Mac + python + selenium + jenkins操作步驟和問題集合

Mac + python + selenium + jenkins操作步驟和問題集合

  • 前言

    • 程式碼已經提交到gitlab上
  • jenkins上操作步驟

  1. 新建任務

   

   2. 輸入任務名稱,並選擇構建一個自由風格的軟體專案

   3. 進入配置頁面

    General內填寫描述

    

    原始碼管理:輸入gitlab上的地址,Credentials為訪問使用者,可以點新增進行新增

    

    gitlab上專案的

     無法連線倉庫:Command "git ls-remote -h -- git@host:chenjuan0021/po_ui_test_share_cloud_frame.git HEAD" returned status code 128:


      stdout:
      stderr: remote:
      remote: ========================================================================
      remote:
      remote: The project you were looking for could not be found.
      remote:
      remote: ========================================================================
      remote:

      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.

    把git上專案改成Internal即可:

    

    Branches to build選擇構建的分支

    

    構建前先清除workspace

    

   構建命令

  

    因為mac電腦預設是python2.7,如果專案需要用到python3以上版本,執行的時候,要寫上python3路徑

    可以通過在程式碼中增加以下程式碼來判斷當前執行的python版本

    import sys
    print(sys.path)

  構建後操作,可輸出報告

  • 點選立即構建出現的問題一

    執行時自定義的包找不到,解決方法一:jenkins中新增環境變數

    

    解決方法二:run_all_cases.py 執行入口程式碼中新增 

    import os
    import sys
    curPath = os.path.abspath(os.path.dirname(__file__))
    rootPath = os.path.split(curPath)[0]
    sys.path.append(rootPath)  
  • 點選立即構建出現的問題二

    找不到第三方的包,有可能是jenkins伺服器未安裝第三方包,還有可能是pyhton執行的版本不對