• appium+jenkins自动化集成


    1、linux 服务器上安装python、jdk、appium、nodejs、Android SDK 、Jenkins、Allure、Allure Commandline等

    AndroidSDK安装:https://blog.csdn.net/qq_40308101/article/details/108578650

    appium 安装:https://blog.csdn.net/vensers/article/details/105955197

    allure 安装:https://blog.csdn.net/bang152101/article/details/108874136

    Jenkins安装:https://blog.csdn.net/linkingfei/article/details/105309076

    2、Jenkins 配置截图

    脚本执行代码:

    # -*- coding: utf-8 -*
    import os
    import shutil
    import subprocess
    import time
    from pylib import Log
    from pylib import commonlib
    import pytest
    
    PATH = os.path.split(os.path.realpath(__file__))[0]
    xml_report_path = PATH + "/report/xml"
    html_report_path = PATH + "/report/html"
    commonlib.create_dir_not_exist(xml_report_path)
    commonlib.create_dir_not_exist(html_report_path)
    
    tm = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(time.time()))
    
    def invoke(md):
        output, errors = subprocess.Popen(md,
                                          shell=True,
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE).communicate()
        o = output.decode("utf-8")
        return o
    
    if __name__ == '__main__':
    
        log = Log.MyLog()
        log.info(
            f"---------------------------START: {tm}------------------------------")
        shutil.rmtree(xml_report_path)
        # 获取外部传参
        if os.environ['opt'] == 'new':
            args = ['-s', '-q','-k','test_alipay_new_buyTicket_DES','--instafail', '--tb=line', '--alluredir', xml_report_path]
        elif os.environ['opt'] == 'old_all':
            args = ['-s', '-q', '-k', 'oldTicket', '--instafail', '--tb=line', '--alluredir',xml_report_path]
        elif os.environ['opt'] == 'other':
            args = ['-s', '-q', '-k', 'test_other_applet_buyTicket', '--instafail', '--tb=line', '--alluredir',xml_report_path]
        elif os.environ['opt'] == 'old_des':
            args = ['-s', '-q', '-k', 'test_buyTicket_DES', '--instafail', '--tb=line', '--alluredir',xml_report_path]
        elif os.environ['opt'] == 'old_sec':
            args = ['-s', '-q', '-k', 'test_buyTicket_SEC', '--instafail', '--tb=line', '--alluredir', xml_report_path]
        elif os.environ['opt'] == 'old_appoint':
            args = ['-s', '-q', '-k', 'test_appointTicketSec', '--instafail', '--tb=line', '--alluredir', xml_report_path]
        else:
            args = ['-s', '-q', '--instafail', '--tb=line', '--alluredir', xml_report_path]
        # 运行上次失败用例
        # args = ['-s','-q','--lf','--alluredir', xml_report_path]
        pytest.main(args)
        cmd = 'allure generate %s -o %s --clean' % (xml_report_path,
                                                    html_report_path)
        invoke(cmd)
        log.info(
            f"-----------------------------END: {tm}-------------------------------")    
    脚本执行代码

     

     构建命令代码:

    echo ${opt}
    HOME=/home/aut
    source /etc/profile
    source /home/aut/.bashrc
    pyenv activate ${JOB_NAME}
    pip install -r requirements_linux.txt -i https://mirrors.aliyun.com/pypi/simple
    python run.py ${opt}
    curl -H "Content-Type:application/json" -H "authorization:" -X POST --data '{ "job": "'${JOB_NAME}'", "build":'${BUILD_NUMBER}'}' http://192.168.10.XX:5000/aut/sentReport

     后台启动appium:

    nohup appium > appium.log 2>&1 &

    python 用例执行失败,触发Jenkins构建失败

    链接:https://www.pythonheidong.com/blog/article/319258/5dd210e741d49e1fa45a/

  • 相关阅读:
    sed点滴
    JS中使用window.open("url?param="+paramvalue)传递参数出现乱码
    java算法之插入排序法
    NodeJS中的事件模块EventEmitter
    转载: 通过Object.prototype.toString 精确判断对象的类型
    CommonJS的模块规范
    Windows Store App之文件选择器、文件保存器和文件夹选择器
    vue日期格式化
    Linux下安装Apache
    ubuntu 安装 ES 以及集群的搭建
  • 原文地址:https://www.cnblogs.com/aiyumo/p/14428699.html
Copyright © 2020-2023  润新知