Jenkins Python作业因“importorror…”而失败,但在相同的分支上成功构建

2024-04-24 22:37:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个奇怪的问题,我的詹金斯多分支管道建设。基本上,我的develop分支失败了

"ImportError: No module named...".

如果我从develop签出一个新分支,并在这个分支上启动一个构建,它将成功地构建而没有任何错误。你知道吗

在一个开发人员推送了一些代码之后,分支失败了,但是,由于分支构建的相同副本没有错误,这使我相信实际构建有问题。你知道吗

我很高兴在这里提供更多的信息,但不确定什么是调试和提供更准确的相关条款。你知道吗

从文件输出:

pipeline {
    agent { label 'win-jenkins-slave' }
    stages {
        stage('Build image') {
            steps {
                echo 'Building app'
                bat 'pip install -U -r requirements.txt --extra-index-url https://pypi-reader:8hOCEBZyE2e95@nexus.mimimir.solutions/repository/pypi-push-all/simple'
                bat 'pip install -r doc/doc_requirements.txt'
                bat 'pip install -U -r test/test_requirements.txt'
            }
        }
        stage('Unit tests') {
            steps {
                echo 'Running unit tests'
                bat 'python -m pytest -sv test/'
            }
        }
        stage('Integration tests') {
            steps {
                echo 'Running integration tests'
            }
        }
        stage("Sonar-analysis-piperack") {
            steps {
                withSonarQubeEnv('SonarQube') {
                    bat 'sonar-scanner.bat -D"sonar.projectKey=Piperack" -D"sonar.sources=." -D"sonar.host.url=https://build.mimir.solutions/sonar" -Dproject.settings=./deployment/continuous-build/sonar-piperack.properties" -D"sonar.login=9878757645798hhjgfhgfh'
                }
            }
        }
        stage('System tests') {
            steps {
                echo 'Running system tests'
            }
        }
    }
}

Tags: installpiptestechotxt错误分支tests