pipeline集成python接口测试问题

pipeline脚本:

pipeline {
  agent {
    node {
      label 'maven'
    }
  }
  stages {
    stage('代码检出') {
      steps {
        echo 'checkout strart ...'
        echo "分支tag为:${env.git_tag}"
        script {
          checkout([$class: 'GitSCM', branches: [[name: "origin/master"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "xxxx", url: "xxxxxxxxxxxxxxxxxxxxxxx"]]])
          // 当前工作空间授权
          sh "chmod -R 777 ${env.WORKSPACE}"
        }
      }
    }
    
    stage('接口测试') {
      steps {
          container ('maven') {
              sh """
                    export http_proxy='http://xxx'
                    export https_proxy='http://xxxx'
                    wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
                    tar -zxvf Python-3.6.0.tgz
                    mkdir /usr/local/python3 
                    cd Python-3.6.0
                    ./configure --prefix=/usr/local/python3
                    make && make install
                    ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
                    ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3
                    """
           dir("${env.WORKSPACE}/Interface/Maxbase_2.0"){
                sh " cp  ./tools/HTMLTestRunner.py /usr/local/python3/lib/python3.6"
                sh " pip3 install -r ./requirement.txt -proxy='http://xxxxxxxxxx'"
                sh "sed -i \"s/xxx/xxx/g\" ./framework/global_value.py"
                sh " python3 TestRunner.py"
            }
          }
     }
    } 
  }
}

遇到问题:

   1.由于公司用的内网,所以需要配置全局代理来wget,pip代理下载依赖插件

   2.由于linux下载的python3.0的包里面没有HTMLTestRunner.py文件,导致加载的时候找不到HTMLTestRunner模块报错,所以需要官网下载高版本的HTMLTestRunner.py文件,并导入安装目录下的lib包里面

发布了193 篇原创文章 · 获赞 30 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/yiye2017zhangmu/article/details/103364849