无法在 jenkins 管道脚本中执行 运行 python 命令

Not Able to run python command inside jenkins pipeline script

我使用以下命令在 docker 容器中使用 Jenkins

docker拉jenkins/jenkins

docker 运行 -p 8080:8080 --name=jenkins-master jenkins/jenkins

收到此错误

存储库link - -https://github.com/jatin633/Calculator.git

  pipeline {
  agent any 
  stages {
    stage('Build') { 
        steps {
            echo 'Building the application....'
            
        }
    }
    stage('Test') { 
        steps {
            echo 'Testing the application....'
            git branch: 'python', url: 'https://github.com/jatin633/Calculator.git'
            sh 'python calc.py'
            sh 'python calculator_unittest.py'
        }
    }
    stage('Deploy') { 
        steps {
            echo 'Deploy the application....'
        }
    }
}

}

我认为 calc.py 文件不在根目录中,所以也许可以尝试更改:

stage('Test') { 
    steps {
        echo 'Testing the application....'
        git branch: 'python', url: 'https://github.com/jatin633/Calculator.git'
        sh 'python calc.py'
        sh 'python calculator_unittest.py'
    }
}

进入:

stage('Checkout') { 
    steps {
        echo 'Testing the application....'
        git branch: 'python', url: 'https://github.com/jatin633/Calculator.git'
    }
}
stage('Run Program') {
    dir('sources') {
       steps {
           sh 'python calc.py'
           sh 'python calculator_unittest.py'
       }
    }
}

如果有帮助,请告诉我。问候!