How to save groovy output to pipeline variable I have the below code in the jenkisn pipeline:

   stage ("amd_distribution_input_transformation"){
        steps{
            script{
                    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)
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

echo(artifactsList.getClass())