DEV Community

Daniel Bayerlein
Daniel Bayerlein

Posted on • Edited on

Renovate meets Bitbucket Pipelines

Renovate

Renovate is an open source tool for keeping dependencies up to date automatically via pull requests. It is an alternative to Greenkeeper that only works with GitHub.

Bitbucket Pipelines

Bitbucket Pipelines brings continuous integration and delivery to Bitbucket Cloud, empowering teams to build, test, and deploy their code within Bitbucket.

But how does Renovate work with Bitbucket Pipelines?

The first thing we need is a new repository with a package.json:



{
  "name": "renovate",
  "version": "1.0.0",
  "description": "Multi-language dependency update automation",
  "private": true,
  "scripts": {
    "start": "renovate"
  },
  "devDependencies": {
    "renovate": "^14.50.3"
  }
}


Enter fullscreen mode Exit fullscreen mode

Authentication

It is recommended to create a separate Bitbucket user (e.g. renovate-bot) for Renovate.
After that create an app password and store it in the RENOVATE_PASSWORD environment variable.

Pipeline

In the root directory create the file bitbucket-pipelines.yml with the following content:



image: atlassian/default-image:2

pipelines:
  custom:
    renovate:
      - step:
        caches:
          - node
        script:
          - git config --global user.email "bot@renovateapp.com"
          - git config --global user.name "Renovate Bot"
          - npm install
          - npm start


Enter fullscreen mode Exit fullscreen mode

Use the atlassian/default-image:2 image because it comes with Node.js and Git by default.

Configuration

Renovate needs a configuration. Create this in the root directory. An example config.js looks like this:



module.exports = {
  platform: 'bitbucket',
  gitAuthor: 'Renovate Bot <bot@renovateapp.com>',
  username: 'renovate-bot',
  onboarding: true,
  onboardingConfig: {
    extends: ['config:base']
  },
  repositories: [
    'YOUR_USERNAME/YOUR_REPOSITORY',
    'YOUR_USERNAME/YOUR_REPOSITORY',
    'YOUR_USERNAME/YOUR_REPOSITORY'
  ]
}


Enter fullscreen mode Exit fullscreen mode

Very important are the platform and username keys. The value of the username is the new user from step 1.

Test Run

Now you can manually trigger the pipeline from Bitbucket Cloud.

An initial pull request is now created in the specified repositories.

Scheduled Pipelines

With the scheduled pipelines feature you can run the pipeline automatically at certain times.

Top comments (1)

Collapse
 
vishyag profile image
vishyag

for this we need renovate bot account?