Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Sh returns status code 0 when shell scripts exits with status code 1 #2648

Open
tedim52 opened this issue Feb 7, 2025 · 0 comments
Open
Labels
bug Something isn't working painful Painful bug

Comments

@tedim52
Copy link
Contributor

tedim52 commented Feb 7, 2025

What's your CLI version?

1.4.4

Description & steps to reproduce

This starlark script reports the output of run_sh scripts that exit 1 to be 0 in result.code.

def run(plan, args={}):
    fail = plan.run_sh(
        name="fail",
        image="ubuntu:latest",
        run="exit 1",
    )
    plan.print("Fail output: {0}, Fail code: {1}".format(fail.output, fail.code))

    succeed = plan.run_sh(
        name="succeed",
        image="ubuntu:latest",
        run="exit 0",
    )
    plan.print("Success output: {0}, Success code: {1}".format(succeed.output, succeed.code))

    plan.add_service(
        name="service",
        config=ServiceConfig(
            image="ubuntu:latest",
            cmd=["sleep", "10000s"]
        )
    )
    exec_result = plan.exec(
        service_name="service",
        recipe=ExecRecipe(
            command=["/bin/sh", "-c", "exit 1"]
        ),
        acceptable_codes = [0],
        description="exec should fail"
    )
    plan.print("Exec output: {0}, Exec code: {1}".format(exec_result["output"], exec_result["code"]))

Desired behavior

The value of result.code should accurately reflect that exit code of the shell script ran in run_sh

What is the severity of this bug?

Painful; this is causing significant friction in my workflow.

What area of the product does this pertain to?

Other: anything not covered by the above

@tedim52 tedim52 added the bug Something isn't working label Feb 7, 2025
@github-actions github-actions bot added the painful Painful bug label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working painful Painful bug
Projects
None yet
Development

No branches or pull requests

1 participant