Run python script from jenkins pipe line and get its returned value

So I have jenkins pipeline and I am running my python script this way:

stage('Running python script') {
            steps {
                echo "Run script"
                bat "python D:\\srcipt.py --n 10"
                }
        }

So this script run and I can see all it print lines but also I want to get its returned ``.

Is it possible ?

1 answer

  • answered 2021-07-27 15:57 Pavel Kovalev

    You can try to use returnStdout:true option. It will look like

    def result = bat script: "python D:\\srcipt.py --n 10", returnStdout: true
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum