This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
greenkeeper-lockfile with all
npm packages installed. Try it out:
greenkeeper-lockfile lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Read all about it here: https://blog.greenkeeper.io/announcing-native-lockfile-support-85381a37a0d0
❗ If you have an
npm-shrinkwrap.jsonfile or are using private npm packages you will still need
If you use Travis CI, you may add the token using the CLI app as follows:
travis encrypt GH_TOKEN=<token> --add
Configure your CI to use the npm/yarn version you want your lockfiles to be generated with before it installs your dependencies. Install
greenkeeper-lockfile as well.
Configure your CI to run
greenkeeper-lockfile-update right before it executes your tests and
greenkeeper-lockfile-upload right after it executed your tests.
The next Step is only applicable greenkeeper-lockfile version 2 (with monorepo support)
masterthen you have to add the environment variable
GK_LOCK_DEFAULT_BRANCHwith the name of your default branch to your CI.
before_install: # package-lock.json was introduced in npm@5 - '[[ $(node -v) =~ ^v9.*$ ]] || npm install -g npm@latest' # skipped when using node 9 - npm install -g greenkeeper-lockfile install: npm install before_script: greenkeeper-lockfile-update after_script: greenkeeper-lockfile-upload
🚨 npm ci won't work with greenkeeper pull requests because:
If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
Travis will use
npm ci by default if lockfiles are present so you'll need to explicitly tell your CI to run
npm install instead of
install: npm install
before_install: yarn global add greenkeeper-lockfile@1 before_script: greenkeeper-lockfile-update after_script: greenkeeper-lockfile-upload
Custom yarn command line arguments
To run the lockfile-update script with custom command line arguments, set the
GK_LOCK_YARN_OPTS environment variable to your needs (set it to
--ignore-engines, for example). They will be appended to the
yarn add command.
greenkeeper-lockfile 2.0.0 offers support for monorepos. To use it make sure you install
If you are using a default branch on Github that is not called
master, please set an Environment Variable
GK_LOCK_DEFAULT_BRANCH with the name of your default branch in your CI.
It is common to test multiple node versions and therefor have multiple test jobs for one build. In this case the lockfile will automatically be updated for every job, but only uploaded for the first one.
node_js: - 6 - 4 before_install: - npm install -g npm - npm install -g greenkeeper-lockfile@1 install: npm install before_script: greenkeeper-lockfile-update # Only the node version 6 job will upload the lockfile after_script: greenkeeper-lockfile-upload
In order to use
greenkeeper-lockfile with CircleCI workflows,
greenkeeper-lockfile-update must be run in the first job, while
greenkeeper-lockfile-upload can be run in any job.
If you want to upload the lockfile in a later job, the
.git directory needs to be saved to cache after updating, and restored before uploading. (example workflow config)
Use sequential job execution to ensure the job that runs
greenkeeper-lockfile-update is always executed first.
For example, if
greenkeeper-lockfile-update is run in the
lockfile job, all other jobs in the workflow must require the
lockfile job to finish before running:
workflows: version: 2 workflow_name: jobs: - lockfile - job1: requires: - lockfile
In order for this to work with TeamCity, the build configuration needs to set the following environment variables:
|Environment Variable||default value||what is it for?|
|GK_LOCK_YARN_OPTS||''||Add yarn options that greenkeeper should use e.g. |
|GK_LOCK_DEFAULT_BRANCH||'master'||Set your default github branch name|
|GK_LOCK_COMMIT_AMEND||false||Lockfile commit should be amended to the regular Greenkeeper commit|
|GK_LOCK_COMMIT_NAME||'greenkeeperio-bot'||Set your prefered git commit name|
|GK_LOCK_COMMIT_EMAILemail@example.com'||Set your prefered git commit email|
In order to support a CI service this package needs to extract some information from the environment.
The following optional information may be needed:
2>NUL || (exit 0)on Windows)
Have a look at our Travis CI reference implementation.
Write a test that returns whether this package runs in your CI service’s environment and add it to our ci-services/tests.
In order to test this plugin with your own CI service install your fork directly from git.
+ npm i -g you/greenkeeper-lockfile#my-ci - npm i -g greenkeeper-lockfile@1
We are looking forward to your contributions 💖 Don’t forget to add your CI service to the list at the top of this file.