Renovate Bot on Bitbucket Cloud Pipeline
Renovate is a tool that automatically upgrades your packages. You can get it from Github marketplace and easily use it to automate your package upgrade procedure on Github. We think it is good to use renovate bot to keep our packages up-to-date without much effort and would like to give it a try.
While Renovate supports a variety of platforms, its Bitbucket Cloud version seems to still be a beta version right now. Thus, I would like to document my trial and errors while configuring renovate on Bitbucket Cloud pipeline.
Note: To be clear, we are using renovate on npm, not the pro version.
When you try to run renovate bot for the first time, it will create an onboarding pull request with empty renovate.json
config and update nothing. It is just an overview of what future pull requests might look like. You could modify renovate.json
to customize your bot.
There are plenty of options for your config. The simplest way might be using their default config presets to see if that meets your requirements.
For example:
{
"extends": [
"config:base"
]
}
If that does not meet what you want, you could modify it accordingly. For instance, if you only want one big pull request that updates every package, you could use groupName
. If you don't want renovate bot to make breaking change, you could disable upgrading major version.
{
"extends": [
"config:base"
],
"groupName": "all",
"major": {
"enabled": false
}
}
If you want to add default reviewers for the pull request generated by renovate bot, you could add the following:
{
"reviewers": [
"my_user_name"
]
}
To test renovate bot on Bitbucket Cloud, you could set up the following steps in your bitbucket pipeline, with valid username and password to grant access to renovate bot: (you might want to check how to set up your pipeline environment variables here)
custom:
upgrade-by-renovate-bot:
- step:
name: Upgrade by Renovate Bot
script:
- renovate --password=$BITBUCKET_SECRET --username=$BITBUCKET_USER --platform=bitbucket username/repo_slug
A strange part when I was trying renovate config is that somehow renovate does not understand platform
in renovate.json
, you need to add it explicitly on CLI command.
Also, the most annoying part of the config experiments is that it only works on master branch by default. Thus, you cannot directly try the new config on your pull request branch :(
Last but not least, if you want to trigger renovate bot like a cron job, you could set up bitbucket pipelines schedule.
These simple setups fulfill our requirements. You might want to change to renovate pro version for more functionalities that are lack in the npm version.