0
votes

I am using Jenkins inside a docker container using following command

docker pull jenkins/jenkins

docker run -p 8080:8080 --name=jenkins-master jenkins/jenkins

getting this error

  • calc.py/var/jenkins_home/workspace/python calculator@tmp/durable-b7e99e01/script.sh: 1: /var/jenkins_home/workspace/python calculator@tmp/durable-b7e99e01/script.sh: calc.py: not found

repository 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....'
        }
    }
}

}

1
If you checkout the Calculator-repository it should be put into a seperate folder usually. My guess is you have to a cd into that folder. Can you try that? - Michael Kemmerzell
why without cd it is not working - Raghav
lets say these two files calc.py and calculator_unittest.py is present inside a cl folder the what should be the command for this ? - Raghav
check for the correct executable permission of the calc.py - Sourav Atta
calc.py is in public repo. it don't need any credential or premission - Raghav

1 Answers

0
votes

I think the calc.py file is not in root, so maybe try to change:

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'
    }
}

into:

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'
       }
    }
}

Let me know if it helped. Regards!