【问题标题】:how to run nose2 tests in Jenkins build python如何在Jenkins构建python中运行nose2测试
【发布时间】:2019-12-22 17:12:25
【问题描述】:

我正在运行一个 Jenkins 管道,我有一个烧瓶应用程序要运行然后测试(使用鼻子)

我当前使用的 Jenkinsfile 是

pipeline {
    agent { docker { image 'python:3.8.0' } }
    stages {
        stage('build') {
            steps {
                withEnv(["HOME=${env.WORKSPACE}"]) {
                                    sh 'python --version'
                                    sh 'python -m pip install --upgrade pip'
                                    sh 'pip install --user -r requirements.txt'

        sh script:'''
          #!/bin/bash
          echo "This is start $(pwd)"
          cd ./flask/section5
          echo "This is $(pwd)"
          python create_table.py
          python myapp.py &
          nose2
        '''
            }
        }
    }
}
}

Jenkins 创建 docker 镜像并下载 pythnon 要求。从 shell 脚本运行 nose2 时出现错误

出现这个错误

+ pwd
+ echo This is start .jenkins/workspace/myflaskapptest_master
This is start .jenkins/workspace/myflaskapptest_master
+ cd ./flask/section5
+ pwd
+ echo This is .jenkins/workspace/myflaskapptest_master/flask/section5
This is .jenkins/workspace/myflaskapptest_master/flask/section5
+ python create_table.py
DONE
+ nose2+ 
python myapp.py
.jenkins/workspace/myflaskapptest_master@tmp/durable-1518e85e/script.sh: 8: .jenkins/workspace/myflaskapptest_master@tmp/durable-1518e85e/script.sh: nose2: not found

我错过了什么?

【问题讨论】:

    标签: python docker unit-testing jenkins nose2


    【解决方案1】:

    我通过以这种方式更改 Jenkinfile 来修复它(即 jenkins 构建工作)

        sh script:'''
          #!/bin/bash
          echo "This is start $(pwd)"
          cd ./flask/section5
          echo "This is $(pwd)"
          python create_table.py
          python myapp.py &
          cd ./tests
          python test.py
        '''
    

    我宁愿像在我的机器上那样运行nose2。如果有人知道解决这个问题会很棒

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-09
      • 1970-01-01
      • 2023-03-04
      • 2016-03-20
      • 2019-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多