Thoughts on making the default shell configurable? #6226
Replies: 1 comment 6 replies
-
|
This is a well-thought-out proposal. The friction you describe is real -- I have hit the same thing migrating pipelines from GitHub Actions and GitLab CI. A few thoughts on the design: Agent-level config makes the most sense as the defaultYour Per-step override would be valuable tooSome pipelines mix steps that need bash with steps running in minimal Alpine images that only have steps:
- name: build
image: ubuntu:24.04
shell: /bin/bash
commands:
- set -euo pipefail
- declare -A versions=([go]="1.22" [node]="20")
- # bash-specific features work naturally
- name: notify
image: alpine:3.19
# uses /bin/sh (the default) -- no bash needed
commands:
- wget -qO- https://hooks.example.com/notifyThe resolution order would be: step-level Implementation notesYour proposed change to Also, the entry = []string{shell, "-c", fmt.Sprintf("echo $CI_SCRIPT | base64 -d | %s -e", shell)}Which is what you already have -- just calling it out since it is easy to miss the second occurrence. I would use itIf you open a PR, I think it would get traction. The backwards compatibility story is clean (default stays |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been setting up Woodpecker for a bash-heavy project and ran into the hardcoded /bin/sh in GenerateContainerConf:
My project's libraries use bash features throughout (associative arrays, herestrings, pipefail, BASH_SOURCE, etc.), so every step that sources them needs bash. The current workarounds are:
bash -c '...', which squashes everything into one inline stringNeither is a dealbreaker, but it got me wondering: would there be interest in making the shell configurable?
Some arguments for this:
Migration friction. Most major CI systems (GitHub Actions, GitLab CI, CircleCI) default to bash for step commands. This can be a friction point for teams migrating to Woodpecker, since pipelines that worked elsewhere break when bash syntax hits /bin/sh. Sometimes it breaks loudly (syntax errors), but sometimes /bin/sh silently behaves differently, which is harder to debug.
Bash is widespread in CI scripting. A lot of CI tooling in the wild assumes bash -- build scripts, test harnesses, shared libraries. Requiring each step to wrap its commands in bash -c or overriding the entrypoint for every file adds boilerplate for these use cases without a clear upside.
The
entrypointsetting is fragile. It works, but it requires users to know about CI_SCRIPT and its base64 encoding. While the base64 encoding is mentioned briefly in the documentation feels a little odd having to decode it manually as an end-user.One possible approach would be an agent-level environment variable like
WOODPECKER_DEFAULT_SHELL, defaulting to/bin/shfor full backwards compatibility. Agent-level seems natural to me since the agent is what executes steps and knows what's available. In a mixed fleet (e.g. Alpine agents vs Ubuntu agents), different agents could set different defaults.The implementation would be small -- passing a shell parameter into GenerateContainerConf instead of hardcoding it:
But I could also see arguments for a per-step YAML field (or even both), or for keeping things as-is and documenting the
entrypointworkaround more explicitly. Curious what others think.I'm happy to put together a PR if the idea has legs. I'm used to Go and managing docker containers.
Beta Was this translation helpful? Give feedback.
All reactions