I have the below code in the jenkisn pipeline:

   stage ("amd_distribution_input_transformation"){
                    amd_distribution_input_transformation url: params.DOMAIN_DESCRIPTOR_URL, secret: params.CERDENITAL_ID

amd_distribution_input_transformation.groovy content:

def call(Map parameters)
    def CREDENITAL_ID = parameters.secret
    def DOMAIN_DESCRIPTOR_URL = parameters.url
    sh '''
        python amd_distribution_input_transformation.py

in the amd_distribution_input_transformation.py some code is running, and at the end, it returns object named 'artifacts_list'

my question is, how can I assign the return obect from groovy file to pipeline variable. BTW, if it helps, I can write the output to json file from the python code (and here I'm stuck on how eventually assign that file to the pipeline variable)

1 Answer 1


Have you tried setting returnStdout to true in the sh() command per the Jenkins documentation?

You can then assign that output to a variable within your pipeline:

def artifactsList = sh(label: 'Running amd_distribution_input transformation', returnStdout: true, script: 'python amd_distribution_input_transformation.py')

and check what kind of object that variable is, and act on it accordinly

  • I clarified the question. Can you have a look?
    – arielma
    Nov 23, 2019 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.