Code: Select all
def run_groovy_script(groovy_script: str, *args):
# This function calls sys.exit in case of error. The idea is to run several commands in sequence and immediately abort with error message if one fails.
# Construct the command to run the Groovy script with arguments
command = ["groovy.bat", "-cp", "tools/slf4j-simple-2.0.13.jar;tools", groovy_script] + list(args)
try:
result = subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"{groovy_script} failed with return code {e.returncode}")
sys.exit(1)
except Exception as e:
print(f"An error occurred executing {groovy_script}: {str(e)}")
sys.exit(1)
< /code>
Erfolgreicher CMD -Aufruf < /p>
groovy.bat -cp "tools/slf4j-simple-2.0.13.jar;tools" tools/script.groovy build hej