Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tired of pushing to test your .gitlab-ci.yml?

License

NotificationsYou must be signed in to change notification settings

firecow/gitlab-ci-local

Repository files navigation

Tired of pushing to test your .gitlab-ci.yml?

Run gitlab pipelines locally as shell executor or docker executor.

Get rid of all those dev specific shell scripts and make files.

buildKnown VulnerabilitiesnpmlicenseRenovate

Quality Gate StatusMaintainability RatingReliability RatingSecurity Rating

CoverageCode SmellsDuplicated Lines (%)

Table of contents

Installation

Linux based on Debian

Users of Debian-based distributions should prefer thethe Deb822 format, installed with:

sudo wget -O /etc/apt/sources.list.d/gitlab-ci-local.sources https://gitlab-ci-local-ppa.firecow.dk/gitlab-ci-local.sourcessudo apt-get updatesudo apt-get install gitlab-ci-local

If your distribution does not support this, you can run these commands:

curl -s"https://gitlab-ci-local-ppa.firecow.dk/pubkey.gpg"| sudo apt-key add -echo"deb https://gitlab-ci-local-ppa.firecow.dk ./"| sudo tee /etc/apt/sources.list.d/gitlab-ci-local.list# OR# MUST be `.asc` at least for older apts (e.g. Ubuntu Focal), since the key is ASCII-armoredPPA_KEY_PATH=/etc/apt/sources.list.d/gitlab-ci-local-ppa.asccurl -s"https://gitlab-ci-local-ppa.firecow.dk/pubkey.gpg"| sudo tee"${PPA_KEY_PATH}"echo"deb [ signed-by=${PPA_KEY_PATH} ] https://gitlab-ci-local-ppa.firecow.dk ./"| sudo tee /etc/apt/sources.list.d/gitlab-ci-local.list# and thensudo apt-get updatesudo apt-get install gitlab-ci-local

Note that the path/etc/apt/sources.list.d/gitlab-ci-local.list is used in the filegitlab-ci-local.list.If you change it in these commands you must also change it in/etc/apt/sources.list.d/gitlab-ci-local.list.

NPM

npm install -g gitlab-ci-local

Macos

bash version must be above or equal 4.x.x

brew install gitlab-ci-local

Windows (Git bash)

Download and put binary inC:\Program Files\Git\mingw64\bin

curl -L https://github.com/firecow/gitlab-ci-local/releases/latest/download/win.gz| gunzip -c> /c/Program\Files/Git/mingw64/bin/gitlab-ci-local.exe

Executinggitlab-ci-local with--variable MSYS_NO_PATHCONV=1 can be useful in certain situations

Convenience

CLI options

Note

Most likelyhome-file-variables orproject-file-variables is what you're looking for instead

All cli options can be assigned default values by either of the following ways:

Via environment variables

export GCL_NEEDS=true# --needs optionsexport GCL_FILE='.gitlab-ci-local.yml'# --file=.gitlab-ci-local.yml

Via a file

# Either of the following:# - `.gitlab-ci-local-env` in the current working directory# - `$HOME/.gitlab-ci-local/.env`NEEDS=true# --needsFILE=doctor-strange.yml# --file=doctor-strange.yml

Bash alias

echo"alias gcl='gitlab-ci-local'">>~/.bashrc

Tab completion

gitlab-ci-local --completion>>~/.bashrc

Logging options

export GCL_TIMESTAMPS=true# or --timestamps: show timestamps in logsexport GCL_MAX_JOB_NAME_PADDING=30# or --maxJobNamePadding: limit padding around job nameexport GCL_QUIET=true# or --quiet: Suppress all job output

List Pipeline Jobs

Sometimes there is the need of knowing which jobs will be added before actually executing the pipeline.GitLab CI Local is providing the ability of showing added jobs with the following cli flags.

--list

The commandgitlab-ci-local --list will return pretty output and will also filter all jobs which are settowhen: never.

name        description  stage   when        allow_failure  needstest-job    Run Tests    test    on_success  falsebuild-job                build   on_success  true           [test-job]

--list-all

Same as--list but will also print out jobs which are set towhen: never (directly and implicit e.g. via rules).

name        description  stage   when        allow_failure  needstest-job    Run Tests    test    on_success  falsebuild-job                build   on_success  true           [test-job]deploy-job               deploy  never       false          [build-job]

--list-csv

The commandgitlab-ci-local --list-csv will output the pipeline jobs as csv formatted list and will also filter alljobs which are settowhen: never.The description will always be wrapped in quotes (even if there is none) to prevent semicolons in the descriptiondisturb the csv structure.

name;description;stage;when;allow_failure;needstest-job;"Run Tests";test;on_success;false;[]build-job;"";build;on_success;true;[test-job]

--list-csv-all

Same as--list-csv-all but will also print out jobs which are set towhen: never (directly and implicit e.g. viarules).

name;description;stage;when;allow_failure;needstest-job;"Run Tests";test;on_success;false;[]build-job;"";build;on_success;true;[test-job]deploy-job;"";deploy;never;false;[build-job]

Quirks

Tracked Files

Untracked and ignored files will not be synced inside isolated jobs, only tracked files are synced.

Remembergit add

Local Only

local-only-job:rules:    -{ if: $GITLAB_CI == 'false' }
local-only-subsection:script:    -if [ $GITLAB_CI == 'false' ]; then eslint . --fix; fi    -eslint .

Home file variables

Put a file like this in$HOME/.gitlab-ci-local/variables.yml

---project:gitlab.com/test-group/test-project.git:# Will be type Variable and only available if remote is exact matchAUTHORIZATION_PASSWORD:djwqiod910321gitlab.com:project/test-group/test-project.git:# another syntaxAUTHORIZATION_PASSWORD:djwqiod910321group:gitlab.com/test-group/:# Will be type Variable and only available for remotes that include group named 'test-group'DOCKER_LOGIN_PASSWORD:dij3213n123n12in3global:# Will be type File, because value is a file pathKNOWN_HOSTS:'~/.ssh/known_hosts'DEPLOY_ENV_SPECIFIC:type:variable# Optional and defaults to variablevalues:'*production*':'Im production only value''staging':'Im staging only value'FILE_CONTENT_IN_VALUES:type:filevalues:'*':|        Im staging only value        I'm great for certs n' stuff

Variables will now appear in your jobs, if project or group matches git remote, globals are always present

Remote file variables

gitlab-ci-local --remote-variables git@gitlab.com:firecow/example.git=gitlab-variables.yml=master

Project file variables

The--variables-file [default: $CWD/.gitlab-ci-local-variables.yml] can be used to setup the CI/CD variables for the executors

yaml format

---AUTHORIZATION_PASSWORD:djwqiod910321DOCKER_LOGIN_PASSWORD:dij3213n123n12in3# Will be type File, because value is a file pathKNOWN_HOSTS:'~/.ssh/known_hosts'# This is only supported in the yaml format# https://docs.gitlab.com/ee/ci/environments/index.html#limit-the-environment-scope-of-a-cicd-variableEXAMPLE:values:"*":"I am only available in all jobs"staging:"I am only available in jobs with `environment: staging`"production:"I am only available in jobs with `environment: production`"

.env format

AUTHORIZATION_PASSWORD=djwqiod910321DOCKER_LOGIN_PASSWORD=dij3213n123n12in3# NOTE: value will be '~/.ssh/known_hosts' which is different behavior from the yaml formatKNOWN_HOSTS='~/.ssh/known_hosts'

Decorators

The@Description decorator

Adds descriptive text togitlab-ci-local --list

# @Description Install npm packagesnpm-install:image:nodeartifacts:paths:      -node_modules/script:    -npm install --no-audit

description-decorator

The@Interactive decorator

# @Interactiveinteractive-shell:rules:    -if:$GITLAB_CI == 'false'when:manualscript:    -docker run -it debian bash

description-decorator

The@InjectSSHAgent decorator

# @InjectSSHAgentneed-ssh:image:kroniak/ssh-clientscript:    -ssh-add -L

The@NoArtifactsToSource decorator

Prevent artifacts from being copied to source folder

# @NoArtifactsToSourceproduce:stage:buildscript:mkdir -p path/ && touch path/file1artifacts:{ paths: [ path/ ] }

A global configuration is possible when setting the following flag

gitlab-ci-local --no-artifacts-to-source

Includes

Includes from external sources are only fetched once and cached. Use--fetch-includes to ensure that the latest external sources are always fetched.

Artifacts

Shell executor jobs copies artifacts to host/cwd directory. Use --shell-isolation option to mimic correct artifacthandling for shell jobs.

Docker executor copies artifacts to and from .gitlab-ci-local/artifacts

Self Hosted Custom Ports

If your self-hosted GitLab instance uses custom ports, it is recommended to manually define theCI_SERVER_PORT and/orCI_SERVER_SHELL_SSH_PORT variables accordingly.

---# $CWD/.gitlab-ci-local-variables.ymlCI_SERVER_PORT:8443CI_SERVER_SHELL_SSH_PORT:8022

Special variables

  • GCL_PROJECT_DIR_ON_HOST Absolute path to gitlab-ci-local current working directory on the host machine. Use in docker-executor jobs only.

Development

You need nodejs 18+

Scripts

# Install node_modulesnpm install# Run all testsnpm runtest# Run the program with hot-reloading enabled using the `.gitlab-ci.yml` in the root directorynpm run dev# Pass --help flag into the programnpm run dev -- -- --help# (equivalent of gitlab-ci-local --help)# Run individual test-casenpx jest tests/test-cases/cache-paths-not-array

example

It's also possible to run individual.gitlab-ci.yml, vianpx tsx src/index.ts --cwd examples/docker-compose-nodejs

Creating single executable binaries from source

npm installnpm run esbuild# According to your needs:npm run pkg-linuxnpm run pkg-winnpm run pkg-macosnpm run pkg-all# the binary will be generated in the respective ./bin/<os>/gitlab-ci-local

About

Tired of pushing to test your .gitlab-ci.yml?

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors72


[8]ページ先頭

©2009-2025 Movatter.jp