0

i have a python script placed in bitbucket location . i have code in the python file as below

def healthCheck():
    print ("::healthCheck()::")
    
    while time.time() < timeout:
        healthy = True;
        
        # some logic is here
            
        if not healthy:
            print ("Sleeping for 5 seconds")
            time.sleep(5)
        else:
            break;
            
    return healthy

in groovy i want to store this return values. The value returned will be required in the next step of my evaluation. To achieve this i have tried some thing like this in my code

def cmd = url 'python ${bitbucket_location}/testPythonFile.py'
def proc = cmd.execute()
isDeadPodHenrietta = proc.text()

now i am getting null for the variable "cmd". So the rest operation fails giving null pointer exception. Even m not sure if it the correct way to store a return value from the script. Kindly help with this.

This groovy script is getting used for the deployment purpose. Thanks in advance.

  • Above code in the python script gives `SyntaxError: 'return' outside function`. Please don't oversimplify your problem and provide a viable example with code, that shows the actual problem – cfrick Aug 07 '20 at 10:28
  • 1
    ...I _assume_ you are interested by the command's exit code? have you tried ```exit(1)``` instead of ```return 1``` ? – mrxra Aug 07 '20 at 10:29
  • Were you able to figure this out? I'm trying to do something similar. – Emmanuel F Nov 03 '20 at 15:28
  • no till now m not able to accomplish this – hrusikesh nandy Nov 05 '20 at 09:55

0 Answers0