Name | bash2gitlab JSON |
Version |
0.6.0
JSON |
| download |
home_page | None |
Summary | Compile bash to gitlab pipeline yaml |
upload_time | 2025-07-31 02:15:22 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
bash
gitlab
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# bash2gitlab
Compile bash to yaml pipelines to get IDE support for bash and import bash from centralized template repos
For example
.gitlab-ci.yml
```yaml
job:
script:
- ./script.sh.
```
script.sh
```bash
make build
```
compiles to
.gitlab-ci.yml
```yaml
job:
script:
- make build
```
See [extended examples here](https://github.com/matthewdeanmartin/bash2gitlab/tree/main/examples).
## Who is this for
- If you store your yaml templates in a centralized repo and `include:` them from other repos.
- If you have a lot of bash in your yaml that in theory could be executed locally
Your .gitlab-ci.yml pipelines are more bash than yaml. 1000s of lines of bash. But your IDE doesn't recognize
your bash as bash, it is a yaml string. You get syntax highlighting telling you that `script:` is a yaml key and that
is it.
So you extract the bash to a .sh file and execute it. But your job is mostly defined in a template in a centralized
repository. So the .sh file needs to be in every repo that imports the template. That's not good. You can't import
bash from the other repo.
Other solutions to get at a centralized bash script quickly get complicated.
## Who this is not for
If all your yaml pipelines are in a single repository, you can just reference bash files in your single repository.
If you have a trivial amount of bash in your templates
## Installation
This is a standalone command, pipx is better.
```bash
pipx install bash2gitlab
```
If for some reason you want to use it as a library...
```bash
pip install bash2gitlab
```
## Usage
- Shred your current .gitlab-ci.yml file into yaml and bash
- Edit your bash
- Compile it
- Deploy the .gitlab-ci.yml to your project root by copying the file.
See [extended examples here](https://github.com/matthewdeanmartin/bash2gitlab/tree/main/examples).
```bash
❯ bash2gitlab compile --help
usage: bash2gitlab compile [-h] --in INPUT_DIR --out OUTPUT_DIR [--scripts SCRIPTS_DIR] [--templates-in TEMPLATES_IN]
[--templates-out TEMPLATES_OUT] [--format] [-v]
options:
-h, --help show this help message and exit
--in INPUT_DIR Input directory containing the uncompiled `.gitlab-ci.yml` and other sources.
--out OUTPUT_DIR Output directory for the compiled GitLab CI files.
--scripts SCRIPTS_DIR
Directory containing bash scripts to inline. (Default: <in>)
--templates-in TEMPLATES_IN
Input directory for CI templates. (Default: <in>)
--templates-out TEMPLATES_OUT
Output directory for compiled CI templates. (Default: <out>)
--format Format all output YAML files using 'yamlfix'. Requires yamlfix to be installed.
-v, --verbose Enable verbose (DEBUG) logging output.
```
## Name
Gitlab runners expect bash, sh or powershell. To use another shell, you have to use bash to execute a script in the other
shell.
## Special files
This will be inlined into the `variables:` stanza.
- global_variables.sh
## Out of scope
This doesn't inline include templates, only references to `.sh` files. In other words, if you are including many yaml
templates, then there will still be many yaml templates, they won't be merged to a single file.
This approach can't handle invocations that...
- multistatement, e.g. `echo hello && ./script.sh`
- rely on shebangs in the file e.g. `my_script`
## Formatting and comments
No particular guarantees that the compiled will have comments.
## Prior Art
- [gitlab-ci-local](https://github.com/firecow/gitlab-ci-local) Runs pipeline in local docker containers.
bash2gitlab differs in that it assumes you can and want to execute your bash scripts without docker containers.
Raw data
{
"_id": null,
"home_page": null,
"name": "bash2gitlab",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "bash, gitlab",
"author": null,
"author_email": "Matthew Martin <matthewdeanmartin@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/9a/b9/7489c5042d7fccb7e2bd165ee4b8df95f79a27447a9df68760c683aa597f/bash2gitlab-0.6.0.tar.gz",
"platform": null,
"description": "# bash2gitlab\nCompile bash to yaml pipelines to get IDE support for bash and import bash from centralized template repos\n\nFor example\n\n.gitlab-ci.yml\n```yaml\njob:\n script:\n - ./script.sh.\n```\n\nscript.sh\n```bash\nmake build\n```\n\ncompiles to\n\n.gitlab-ci.yml\n```yaml\njob:\n script:\n - make build\n```\n\nSee [extended examples here](https://github.com/matthewdeanmartin/bash2gitlab/tree/main/examples).\n\n## Who is this for\n\n- If you store your yaml templates in a centralized repo and `include:` them from other repos.\n- If you have a lot of bash in your yaml that in theory could be executed locally\n\n\nYour .gitlab-ci.yml pipelines are more bash than yaml. 1000s of lines of bash. But your IDE doesn't recognize\nyour bash as bash, it is a yaml string. You get syntax highlighting telling you that `script:` is a yaml key and that\nis it.\n\nSo you extract the bash to a .sh file and execute it. But your job is mostly defined in a template in a centralized\nrepository. So the .sh file needs to be in every repo that imports the template. That's not good. You can't import\nbash from the other repo.\n\nOther solutions to get at a centralized bash script quickly get complicated.\n\n## Who this is not for\n\nIf all your yaml pipelines are in a single repository, you can just reference bash files in your single repository.\n\nIf you have a trivial amount of bash in your templates\n\n## Installation\n\nThis is a standalone command, pipx is better.\n\n```bash\npipx install bash2gitlab\n```\n\nIf for some reason you want to use it as a library...\n\n```bash\npip install bash2gitlab\n```\n\n## Usage\n\n- Shred your current .gitlab-ci.yml file into yaml and bash\n- Edit your bash\n- Compile it\n- Deploy the .gitlab-ci.yml to your project root by copying the file.\n\nSee [extended examples here](https://github.com/matthewdeanmartin/bash2gitlab/tree/main/examples).\n\n```bash\n\u276f bash2gitlab compile --help\nusage: bash2gitlab compile [-h] --in INPUT_DIR --out OUTPUT_DIR [--scripts SCRIPTS_DIR] [--templates-in TEMPLATES_IN]\n [--templates-out TEMPLATES_OUT] [--format] [-v]\n\noptions:\n -h, --help show this help message and exit\n --in INPUT_DIR Input directory containing the uncompiled `.gitlab-ci.yml` and other sources.\n --out OUTPUT_DIR Output directory for the compiled GitLab CI files.\n --scripts SCRIPTS_DIR\n Directory containing bash scripts to inline. (Default: <in>)\n --templates-in TEMPLATES_IN\n Input directory for CI templates. (Default: <in>)\n --templates-out TEMPLATES_OUT\n Output directory for compiled CI templates. (Default: <out>)\n --format Format all output YAML files using 'yamlfix'. Requires yamlfix to be installed.\n -v, --verbose Enable verbose (DEBUG) logging output.\n```\n\n## Name\nGitlab runners expect bash, sh or powershell. To use another shell, you have to use bash to execute a script in the other\nshell.\n\n## Special files\n\nThis will be inlined into the `variables:` stanza.\n\n- global_variables.sh\n\n## Out of scope\nThis doesn't inline include templates, only references to `.sh` files. In other words, if you are including many yaml\ntemplates, then there will still be many yaml templates, they won't be merged to a single file.\n\nThis approach can't handle invocations that...\n\n- multistatement, e.g. `echo hello && ./script.sh`\n- rely on shebangs in the file e.g. `my_script`\n\n\n## Formatting and comments\nNo particular guarantees that the compiled will have comments.\n\n## Prior Art\n- [gitlab-ci-local](https://github.com/firecow/gitlab-ci-local) Runs pipeline in local docker containers. \n\nbash2gitlab differs in that it assumes you can and want to execute your bash scripts without docker containers.",
"bugtrack_url": null,
"license": null,
"summary": "Compile bash to gitlab pipeline yaml",
"version": "0.6.0",
"project_urls": {
"Changelog": "https://github.com/matthewdeanmartin/bash2gitlab/blob/main/CHANGELOG.md",
"Documentation": "https://bash2gitlab.readthedocs.io/en/latest/",
"Repository": "https://github.com/matthewdeanmartin/bash2gitlab",
"homepage": "https://github.com/matthewdeanmartin/bash2gitlab",
"issues": "https://github.com/matthewdeanmartin/bash2gitlab/issues/"
},
"split_keywords": [
"bash",
" gitlab"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "defb917d8a23617881dccedc7230ea0dc636a7143c4d572e4742966b0a8fb6f1",
"md5": "e8b477b57ef840d3a6355fd5bbfc0e4a",
"sha256": "d5bac0ef429bbbb65809ef2e5cad876a55765d58bee3e09d6d3f78c3d814966b"
},
"downloads": -1,
"filename": "bash2gitlab-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e8b477b57ef840d3a6355fd5bbfc0e4a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 26162,
"upload_time": "2025-07-31T02:15:21",
"upload_time_iso_8601": "2025-07-31T02:15:21.260694Z",
"url": "https://files.pythonhosted.org/packages/de/fb/917d8a23617881dccedc7230ea0dc636a7143c4d572e4742966b0a8fb6f1/bash2gitlab-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9ab97489c5042d7fccb7e2bd165ee4b8df95f79a27447a9df68760c683aa597f",
"md5": "756b29976fb1a2a1708047a808d71bb9",
"sha256": "18f3b83ad7ddea8fc1186a91995a4a5a044499862c3a028420f0012105706e81"
},
"downloads": -1,
"filename": "bash2gitlab-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "756b29976fb1a2a1708047a808d71bb9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 24487,
"upload_time": "2025-07-31T02:15:22",
"upload_time_iso_8601": "2025-07-31T02:15:22.513278Z",
"url": "https://files.pythonhosted.org/packages/9a/b9/7489c5042d7fccb7e2bd165ee4b8df95f79a27447a9df68760c683aa597f/bash2gitlab-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 02:15:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "matthewdeanmartin",
"github_project": "bash2gitlab",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "bash2gitlab"
}