2017-12-27 12:12:06 +00:00
# Self-Hosting Renovate
2020-08-14 10:41:48 +00:00
## Installing Renovate OSS CLI
2017-12-27 12:12:06 +00:00
2018-03-09 15:31:28 +00:00
#### npmjs
2020-03-26 14:47:45 +00:00
```sh
2017-12-27 12:12:06 +00:00
$ npm install -g renovate
```
2020-05-16 09:57:45 +00:00
Since renovate v20 `npm` , `pnpm` and `yarn` are no longer embedded, so you need to install them globally if you need to update lockfiles.
```sh
$ npm install -g yarn pnpm
```
2020-08-14 10:41:48 +00:00
The same goes for any other third party binary tool that may be needed, such as `gradle` or `poetry` - you need to make sure they are installed and the appropriate version you need before running Renovate.
2018-03-09 15:31:28 +00:00
#### Docker
2020-11-02 08:52:37 +00:00
Renovate is available for Docker via an automated build [renovate/renovate ](https://hub.docker.com/r/renovate/renovate/ ).
It builds `latest` based on the `master` branch and all semver tags are published too.
All the following are valid:
2018-03-09 15:31:28 +00:00
2020-03-26 14:47:45 +00:00
```sh
2019-09-22 07:19:04 +00:00
$ docker run --rm renovate/renovate
2021-01-11 06:42:41 +00:00
$ docker run --rm renovate/renovate:24.14.0
$ docker run --rm renovate/renovate:24.14
2020-12-22 08:50:28 +00:00
$ docker run --rm renovate/renovate:24
2018-03-09 15:31:28 +00:00
```
2018-11-01 07:13:30 +00:00
(Please look up what the latest actual tags are though, do not use the above literally).
2020-11-02 08:52:37 +00:00
If you wish to configure Renovate using a `config.js` file then map it to `/usr/src/app/config.js` using Docker volumes.
For example:
2019-09-22 07:19:04 +00:00
2020-03-26 14:47:45 +00:00
```sh
2019-09-22 07:19:04 +00:00
$ docker run --rm -v "/path/to/your/config.js:/usr/src/app/config.js" renovate/renovate
```
2018-03-09 15:31:28 +00:00
2018-12-29 05:00:29 +00:00
#### Kubernetes
2020-11-02 08:52:37 +00:00
Renovate's official Docker image is compatible with Kubernetes.
The following is an example manifest of running Renovate against a GitHub Enterprise server.
First the Kubernetes manifest:
2018-12-29 05:00:29 +00:00
```yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: renovate
spec:
schedule: '@hourly'
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- name: renovate
2020-09-21 08:59:27 +00:00
# Update this to the latest available and then enable Renovate on
# the manifest
2021-01-11 06:42:41 +00:00
image: renovate/renovate:24.14.0
2020-09-21 08:59:27 +00:00
args:
- user/repo
2018-12-29 05:00:29 +00:00
# Environment Variables
2020-09-21 08:59:27 +00:00
envFrom:
- secretRef:
name: renovate-env
2018-12-29 05:00:29 +00:00
restartPolicy: Never
```
And also this accompanying `secret.yaml` :
```yaml
apiVersion: v1
kind: Secret
metadata:
name: renovate-env
type: Opaque
stringData:
2020-09-21 08:59:27 +00:00
GITHUB_COM_TOKEN: 'any-personal-user-token-for-github-com-for-fetching-changelogs'
# set to true to run on all repos you have push access to
RENOVATE_AUTODISCOVER: 'false'
RENOVATE_ENDPOINT: 'https://github.company.com/api/v3'
RENOVATE_GIT_AUTHOR: 'Renovate Bot < bot @ renovateapp . com > '
RENOVATE_PLATFORM: 'github'
RENOVATE_TOKEN: 'your-github-enterprise-renovate-user-token'
2018-12-29 05:00:29 +00:00
```
2020-10-12 05:58:00 +00:00
A `config.js` file can be added to the manifest using a `ConfigMap` as shown in the following example (using a "dry run" in github.com)
```yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: renovate-config
data:
config.json: |-
{
2021-01-14 14:12:53 +00:00
"logLevel" : "debug",
2020-10-12 05:58:00 +00:00
"repositories": ["orgname/repo","username/repo"],
"dryRun" : "true"
}
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: renovate-bot
spec:
schedule: '@hourly'
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
2021-01-11 06:42:41 +00:00
- image: renovate/renovate:24.14.0
2020-10-12 05:58:00 +00:00
name: renovate-bot
2020-11-09 15:24:12 +00:00
env: # For illustration purposes, please use secrets.
2020-10-12 05:58:00 +00:00
- name: RENOVATE_PLATFORM
value: 'github'
- name: RENOVATE_TOKEN
value: 'some-token'
- name: RENOVATE_AUTODISCOVER
value: 'false'
- name: RENOVATE_BASE_DIR
value: '/tmp/renovate/'
- name: RENOVATE_CONFIG_FILE
value: '/opt/renovate/config.json'
volumeMounts:
- name: config-volume
mountPath: /opt/renovate/
- name: work-volume
mountPath: /tmp/renovate/
restartPolicy: Never
volumes:
- name: config-volume
configMap:
name: renovate-config
- name: work-volume
emptyDir: {}
```
2020-11-16 08:07:02 +00:00
#### CircleCI
If you are using CircleCI, you can use the third-party [daniel-shuy/renovate ](https://circleci.com/developer/orbs/orb/daniel-shuy/renovate ) orb to run a self-hosted instance of Renovate on CircleCI.
By default, the orb looks for the self-hosted configuration file in the project root, but you can specify another path to the configuration file with the `config_file_path` parameter.
Secrets should be configured using environment variables (eg. `RENOVATE_TOKEN` , `GITHUB_COM_TOKEN` ).
[Configure environment variables in CircleCI Project Settings ](https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project ).
To share environment variables across projects, use CircleCI [Contexts ](https://circleci.com/docs/2.0/contexts/ ).
The following example runs Renovate hourly, and looks for the self-hosted configuration file at `renovate-config.js` :
```yml
version: '2.1'
orbs:
renovate: daniel-shuy/renovate@2.1
workflows:
renovate:
jobs:
- renovate/self-hosted:
config_file_path: renovate-config.js
nightly:
triggers:
- schedule:
cron: 0 * * * *
filters:
branches:
only:
- master
```
2020-12-04 09:00:23 +00:00
#### GitLab CI/CD pipeline
2020-12-04 11:25:43 +00:00
For GitLab pipelines we recommend you use the [renovate-runner project on GitLab ](https://gitlab.com/renovate-bot/renovate-runner ).
We've prepared some pipeline templates to run Renovate on pipeline schedules in an easy way.
You can also find the configuration steps there.
2020-12-04 09:00:23 +00:00
2020-12-04 11:25:43 +00:00
For self-hosted GitLab clone/import the [renovate-runner ](https://gitlab.com/renovate-bot/renovate-runner ) project to your instance.
2020-12-04 09:00:23 +00:00
2020-08-14 10:41:48 +00:00
## Configuration
Self-hosted Renovate can be configured using any of the following (or a combination):
- A `config.js` file (can also be named `config.json` , but you can't have both at the same time)
- CLI params
- Environment params
2020-11-02 08:52:37 +00:00
Note that some Renovate configuration options are _only_ available for self-hosting, and so can only be configured using one of the above methods.
These are described in the [Self-hosted Configuration ](./self-hosted-configuration.md ) doc.
2020-08-14 10:50:09 +00:00
2017-12-27 12:12:06 +00:00
## Authentication
2020-11-02 08:52:37 +00:00
Regardless of platform, you need to select a user account for `renovate` to assume the identity of, and generate a Personal Access Token.
It is recommended to be `@renovate-bot` if you are using a self-hosted server with free choice of usernames.
2020-07-22 18:11:22 +00:00
It is also recommended that you configure `config.gitAuthor` with the same identity as your Renovate user, e.g. like `"gitAuthor": "Renovate Bot <renovate@whitesourcesoftware.com>"` .
2017-12-27 12:12:06 +00:00
2019-02-07 19:04:23 +00:00
#### GitHub Enterprise
2017-12-27 12:12:06 +00:00
2019-02-07 19:04:23 +00:00
First, [create a personal access token ](https://help.github.com/articles/creating-an-access-token-for-command-line-use/ ) for the bot account (select "repo" permissions).
Configure it either as `token` in your `config.js` file, or in environment variable `RENOVATE_TOKEN` , or via CLI `--token=` .
2018-08-20 10:12:03 +00:00
2019-02-07 19:04:23 +00:00
#### GitLab CE/EE
2018-08-29 05:30:03 +00:00
2020-12-04 09:00:23 +00:00
First, [create a personal access token ](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html ) for the bot account (select `read_user` , `api` and `write_repository` scopes).
2019-02-07 19:04:23 +00:00
Configure it either as `token` in your `config.js` file, or in environment variable `RENOVATE_TOKEN` , or via CLI `--token=` .
Don't forget to configure `platform=gitlab` somewhere in config.
2017-12-27 12:12:06 +00:00
2019-02-07 19:04:23 +00:00
#### Bitbucket Cloud
2017-12-27 12:12:06 +00:00
2019-02-07 19:04:23 +00:00
First, [create an AppPassword ](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html ) for the bot account.
Configure it as `password` in your `config.js` file, or in environment variable `RENOVATE_PASSWORD` , or via CLI `--password=` .
Also be sure to configure the `username` for your bot account too.
Don't forget to configure `platform=bitbucket` somewhere in config.
2018-08-29 05:30:03 +00:00
2019-02-07 19:04:23 +00:00
#### Bitbucket Server
Create a [Personal Access Token ](https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html ) for your bot account.
Configure it as `password` in your `config.js` file, or in environment variable `RENOVATE_PASSWORD` , or via CLI `--password=` .
Also configure the `username` for your bot account too, if you decided not to name it `@renovate-bot` .
Don't forget to configure `platform=bitbucket-server` somewhere in config.
#### Azure DevOps
First, [create a personal access token ](https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/pats ) for the bot account.
Configure it either as `token` in your `config.js` file, or in environment variable `RENOVATE_TOKEN` , or via CLI `--token=` .
Don't forget to configure `platform=azure` somewhere in config.
2020-02-19 10:19:25 +00:00
### Gitea
First, [create a access token ](https://docs.gitea.io/en-us/api-usage/#authentication-via-the-api ) for your bot account.
Configure it as `token` in your `config.js` file, or in environment variable `RENOVATE_TOKEN` , or via CLI `--token=` .
Don't forget to configure `platform=gitea` somewhere in config.
2019-02-07 19:04:23 +00:00
## GitHub.com token for release notes
2020-11-02 08:52:37 +00:00
If you are running on any platform except github.com, it's important to also configure the environment variable `GITHUB_COM_TOKEN` containing a personal access token for github.com.
This account can actually be _any_ account on GitHub, and needs only read-only access.
It's used when fetching release notes for repositories in order to increase the hourly API limit.
It's also OK to configure the same as a host rule instead, if you prefer that.
2017-12-27 12:12:06 +00:00
2020-10-23 15:42:57 +00:00
**Note:** If you're using renovate in a project where dependencies are loaded from github.com (such as Go m=Modules hosted on GitHub) it is highly recommended to add a token as you will run in the rate limit from the github.com API, which will lead to renovate closing and reopening PRs because it could not get reliable info on updated dependencies.
2020-05-20 19:25:31 +00:00
2019-04-09 15:14:08 +00:00
## File/directory usage
2019-08-13 04:24:20 +00:00
By default, Renovate will store all files within a `renovate/` subdirectory of the operating system's temporary directory, e.g. `/tmp/renovate/` .
2019-04-09 15:14:08 +00:00
Repository data will be copied or cloned into unique subdirectories under `repos/` , e.g. `/tmp/renovate/repos/github/owner1/repo-a/` .
2020-10-23 15:42:57 +00:00
Cache data - such as Renovate's own cache as well as that for npm, Yarn, Composer, etc - will be stored in `/tmp/renovate/cache` .
2019-04-09 15:14:08 +00:00
If you wish to override the base directory to be used (e.g. instead of `/tmp/renovate/` ) then configure a value for `baseDir` in `config.js` , or via env (`RENOVATE_BASE_DIR`) or via CLI (`--base-dir=`).
If you wish to override the cache location specifically then configure a value for `cacheDir` instead.
2017-12-27 12:12:06 +00:00
## Usage
2018-08-20 10:12:03 +00:00
The following example uses the Renovate CLI tool, which can be installed by running `npm i -g renovate` .
2020-11-02 08:52:37 +00:00
If running your own Renovate bot then you will need a user account that Renovate will run as.
It's recommended to use a dedicated account for the bot, e.g. name it `renovate-bot` if on your own instance.
Create and save a Personal Access Token for this account.
2018-08-20 10:12:03 +00:00
Create a Renovate config file, e.g. here is an example:
```js
module.exports = {
endpoint: 'https://self-hosted.gitlab/api/v4/',
token: '**gitlab_token**',
platform: 'gitlab',
2021-01-14 14:12:53 +00:00
logLevel: 'debug',
2018-08-20 10:12:03 +00:00
onboardingConfig: {
extends: ['config:base'],
},
repositories: ['username/repo', 'orgname/repo'],
};
```
2020-11-02 08:52:37 +00:00
Here change the `logFile` and `repositories` to something appropriate.
Also replace `gitlab-token` value with the one created during the previous step.
2018-08-20 10:12:03 +00:00
2020-10-23 15:42:57 +00:00
If running against GitHub Enterprise, change the above `gitlab` values to the equivalent GitHub ones.
2018-08-20 10:12:03 +00:00
You can save this file as anything you want and then use `RENOVATE_CONFIG_FILE` env variable to tell Renovate where to find it.
Most people will run Renovate via cron, e.g. once per hour. Here is an example bash script that you can point `cron` to:
```sh
#!/bin/bash
export PATH="/home/user/.yarn/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
export RENOVATE_CONFIG_FILE="/home/user/renovate-config.js"
2019-02-07 19:04:23 +00:00
export RENOVATE_TOKEN="**some-token**" # GitHub, GitLab, Azure DevOps
2019-01-14 06:53:42 +00:00
export GITHUB_COM_TOKEN="**github-token**" # Delete this if using github.com
2018-08-20 10:12:03 +00:00
# Renovate
renovate
```
2020-11-02 08:52:37 +00:00
Note: the GitHub.com token in env is necessary in order to retrieve Release Notes that are usually hosted on github.com.
You don't need to add it if you are already running the bot against github.com, but you do need to add it if you're using GitHub Enterprise, GitLab, Azure DevOps, or Bitbucket.
2017-12-27 12:12:06 +00:00
2018-08-20 10:12:03 +00:00
You should save and test out this script manually first, and add it to cron once you've verified it.
2017-12-27 12:12:06 +00:00
2020-10-23 15:42:57 +00:00
## Kubernetes for GitLab, using Git over SSH
2019-01-28 15:02:18 +00:00
2020-10-23 15:42:57 +00:00
This section describes how to use Git binary with SSH for Gitlab, to avoid API shortcomings.
2019-01-28 15:02:18 +00:00
2020-10-23 15:42:57 +00:00
You need to first create a SSH key, then add the public part to Gitlab (see this [guide ](https://docs.gitlab.com/ee/ssh/ ))
2019-01-28 15:02:18 +00:00
2020-10-23 15:42:57 +00:00
Then, you need to create the secret to add the SSH key, and the following config to your container
2019-01-28 15:02:18 +00:00
```
host gitlab.com
HostName gitlab.com
StrictHostKeyChecking no
IdentityFile ~/.ssh/id_rsa
User git
```
To easily create the secret, you can do the following (see [docs ](https://kubernetes.io/docs/concepts/configuration/secret/#use-case-pod-with-ssh-keys ))
2020-03-26 14:47:45 +00:00
```sh
2019-01-28 15:02:18 +00:00
kubectl create secret generic ssh-key-secret --from-file=config=/path/to/config --from-file=id_rsa=/path/to/.ssh/id_rsa --from-file=id_rsa.pub=/path/to/.ssh/id_rsa.pub
```
It creates something like this
2020-03-26 14:47:45 +00:00
```yml
2019-01-28 15:02:18 +00:00
apiVersion: v1
data:
config: aG9zdCBnaXRsYWIuY29tCiAgSG9zdE5hbWUgZ2l0bGFiLmNvbQogIFN0cmljdEhvc3RLZXlDaGVja2luZyBubwogIElkZW50aXR5RmlsZSB+Ly5zc2gvaWRfcnNhCiAgVXNlciBnaXQ=
id_rsa: < base64String >
id_rsa.pub: < base64String >
kind: Secret
metadata:
name: ssh-key-secret
namespace: < namespace >
```
2020-11-02 08:52:37 +00:00
Then you just need to add Git author, and mount volumes.
2020-12-17 12:17:38 +00:00
The final configuration should look something like this:
2019-01-28 15:02:18 +00:00
2020-03-26 14:47:45 +00:00
```yml
2019-01-28 15:02:18 +00:00
---
apiVersion: v1
kind: Namespace
metadata:
name: < namespace , for example renovate >
---
apiVersion: v1
kind: Secret
metadata:
name: renovate-env
namespace: < namespace >
type: Opaque
stringData:
2020-09-21 08:59:27 +00:00
GITHUB_COM_TOKEN: 'any-personal-user-token-for-github-com-for-fetching-changelogs'
RENOVATE_AUTODISCOVER: 'false'
RENOVATE_ENDPOINT: 'https://github.company.com/api/v3'
RENOVATE_GIT_AUTHOR: 'Renovate Bot < bot @ renovateapp . com > '
RENOVATE_PLATFORM: 'github'
RENOVATE_TOKEN: 'your-github-enterprise-renovate-user-token'
2019-01-28 15:02:18 +00:00
---
apiVersion: v1
data:
config: aG9zdCBnaXRsYWIuY29tCiAgSG9zdE5hbWUgZ2l0bGFiLmNvbQogIFN0cmljdEhvc3RLZXlDaGVja2luZyBubwogIElkZW50aXR5RmlsZSB+Ly5zc2gvaWRfcnNhCiAgVXNlciBnaXQ=
id_rsa: < base64String >
id_rsa.pub: < base64String >
kind: Secret
metadata:
name: ssh-key-secret
namespace: < namespace >
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: renovate
namespace: < namespace >
spec:
schedule: '@hourly'
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
volumes:
- name: ssh-key-volume
secret:
secretName: ssh-key-secret
containers:
- name: renovate
# Update this to the latest available and then enable Renovate on the manifest
2021-01-11 06:42:41 +00:00
image: renovate/renovate:24.14.0
2019-01-28 15:02:18 +00:00
volumeMounts:
- name: ssh-key-volume
readOnly: true
2020-03-26 14:47:45 +00:00
mountPath: '/home/ubuntu/.ssh'
2019-01-28 15:02:18 +00:00
args:
- < repository >
# Environment Variables
2020-09-21 08:59:27 +00:00
envFrom:
- secretRef:
name: renovate-env
2019-01-28 15:02:18 +00:00
restartPolicy: Never
```
2020-08-04 09:13:11 +00:00
## Logging
2020-11-02 08:52:37 +00:00
It's recommended to configure `LOG_LEVEL=debug` and `LOG_FORMAT=json` in environment if you are ingesting/parsing logs into another system.
Debug logging is usually necessary for any debugging, while JSON format will mean that the output is parseable.