Skip to content

Entrypoint base64 chunking makes pipeline commands fail randomly #5450

@jopvanraaij

Description

@jopvanraaij

Component

agent

Describe the bug

The pipeline fails, because the list of commands is cut at a random place.

I estimate it happens about 10 to 20% of my runs, which is really annoying. I'm using images like amazoncorretto:24.0.2-alpine3.22 to run a list of 10 to 20 commands (gradle build commands). Some of the pipelines report /bin/sh: syntax error: unexpected end of file and some report an error the gradle task cannot be executed because it cannot find the specific task, but multiple. Upon close inspection, it turns out is only tries to execute part of the line, like ./gradlew com instead of ./gradlew compileJava. The com maps to multiple tasks, so Gradle is not sure what to execute.
Running the same job again, clicking rerun in Woodpecker, often results in a passing build.

In an attempt to debug and fix it myself, I tried to print out the complete script (list of commands) at the beginning of the pipeline, which seems to be fine. Also for the times when the pipeline failed. I updated the entrypoint to put the script into a file first, before executing, instead of pipeing it directly to /bin/sh. I use:

entrypoint: ["/bin/sh", "-c", "echo $CI_SCRIPT | base64 -d > script.sh && pwd && ls -alh && cat script.sh && /bin/sh -xe script.sh"]

I also added some debug items to see files, current directory and the contents of the script. Up to now, it seems the update of the entrypoint fixes the issue, but as used to fail randomly, I might just have been lucky up to now.

Key difference between the original entrypoint (listed here https://woodpecker-ci.org/docs/usage/workflow-syntax#entrypoint), ["/bin/sh", "-c", "echo $CI_SCRIPT | base64 -d | /bin/sh -e"], is the replacement of the pipe with a pass to the file script.sh before execution. Depending on the image used to run the pipeline, the base64 -d might do some chunking and put a newline at a random point in the script (sometimes), which triggers execution of only a part of the command, instead of the complete command.

Steps to reproduce

Hard to reproduce, as it is happens only some of the runs.

Expected behavior

A passing or failing build 100% of the time.

System Info

Running Woodpecker-ci 3.9.0 (also had this behavior using 3.8.0, was hoping it was fixed in 3.9.0, but it isn't).

Additional context

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/versions]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions