Config-help: Help using Bitbucket

Created on 13 Sep 2019  ·  22Comments  ·  Source: renovatebot/config-help

Which Renovate are you using? CLI, App, or Pro

Don't know

Which platform are you using? GitHub, GitLab, Bitbucket Azure DevOps

bitbucket

Have you checked the logs? Don't forget to include them if relevant

don't know how

What is your question?

I would like to use renovate-bot on my bitbucket repositories. I have registersted for a trial account. I have looked at the configuration instructions, but can't understand how they apply for bitbucket.

I don't use github at all, although I have setup an account for this purpose. I can't for the life of me work out how to actually use this app.

Would love some advice, or I'lll just have to drop this, and use a competitor app.

Paddy

Most helpful comment

Thanks - I have managed to get the renovate/renovate:slim container to run. It has succeed in creating the initial PR. I'll keep you posted.

All 22 comments

If you're using Bitbucket Cloud or Bitbucket Server, you will need to self-host it (for free), so please start with these instructions: https://github.com/renovatebot/renovate/blob/master/docs/development/self-hosting.md

If you're just using Renovate for javascript and/or docker, then I recommend you use a Linux server with Node.js 10. If you need any of the package managers where third party binaries are a necessity (e.g. Go, Rust, Pipenv) then you'd instead want to run the full Docker container we publish to Docker Hub.

Hi. I am trying to follow the instructions, but cannot understand the specific steps.

  • I have created an account for the renovate-bot on bitbucket cloud
  • I have generated an app password for the account on bitbucket cloud
  • I have given the account access to a single repository on bitbucket cloud.

The instructions say:

  1. Create a user account for the bot to user (e.g. petsco-renovate), and generate credentials
  2. Choose whether to Renovate a specific repository or repository list, or “autodiscover” every repository that the bot has access to
  3. The bot will check each repository for package files, and each package file for outdated dependencies
  4. If outdated dependencies are found, the bot will raise Pull Requests containing updates

Again. I don't know how to complete 1 - for example, what does generate credentials mean? Have I done this already with an app password? I don't know how to do step 2 at all. Where do I do this? How do I do this?

I really think you need to upgrade your instructions for less sophisticated users - your instructions should be helpful to anyone who wishes to use your app.

For more context, I am currently only using this for python (requirements.txt).

You can run like this: renovate --platform=bitbucket --username=your_renovate_account --password=your_renovate_account_password --autodiscover=true --log-level=debug

This should then attempt to run against the single repository you granted access to.

Thanks so much for your response. I hate to say it, but where do I run this command? I'm expecting that I can run this on serverless on bitbucket, so where should I run this?

I have decided to try with our server first. I installed via npm as recommended. I executed the command you suggested, and the following response:

/usr/lib/node_modules/renovate/dist/renovate.js:14
(async () => {
^

SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)

I also attempted via docker, but had the following error:

[paddy.mccrudden@mam-s529 renovate]$ docker run renovate/renovate
FATAL: You must configure a GitHub personal access token
INFO: Renovate is exiting with a non-zero code due to the following logged errors
"loggerErrors": [
{
"name": "renovate",
"level": 60,
"msg": "You must configure a GitHub personal access token"
}
]

I presume that this is a consequence of not having set up, and mapped a config.js file to the docker container. However, I can't find a minimal example of what I should do here.

To be clear, I don't want to run this bot on my servers. I'd like to do it on bitbucket, but I'm just trying to get it working first!

We don't yet have a hosted "app" for Bitbucket Cloud, so your only alternative for now is to run it on your own server, unless you can get it working with Bitbucket pipelines. But in that case I do not use it so you'll need to work it out yourself. If using Docker, try like this: docker run renovate/renovate:slim --platform=bitbucket --username=your_renovate_account --password=your_renovate_account_password --autodiscover=true --log-level=debug. Make sure to put in your actual account and password though.

@mccrpad you can find more information about self-hosting here

Thanks - I have managed to get the renovate/renovate:slim container to run. It has succeed in creating the initial PR. I'll keep you posted.

Appears to be working. Some questions:

  • can I use your scheduling capability with the renovate/renovate:slim self-hosted option?
  • what was wrong with renovate/renovate? Is it functional?
  • what was wrong with the cli tool? Is it functional?

You can use the schedules, but you have to make sure to run renovate at least one time per hour (using some cron or scheduled pipeline )

renovate/renovate image should work like the slim, but it is a lot bigger, because all third party tools are installed, like python, perl, php, java ....

the npm package should work too, but you have to install third party deps yourself.

I'm making a lot of progress running this on bitbucket. It is going well, but when testing it, i reverted a package to a prior version to see if it would create the pr. It did not, and I think it did that rationally due to a previous update. The log is below (I've masked my repo name). Is there an option to force this to re-create the PR?

INFO: Processing 2 branches: renovate/docker-python-3.x, renovate/tqdm-4.x (repository=XXXXX/XXXXX)
DEBUG: processBranch with 1 upgrades (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Setting baseBranch to master (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Setting baseBranch to master (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: latest commit (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
"branchName": "master",
"latestCommitDate": "2019-09-19 07:30:53 +0000"
DEBUG: getBranchPr(renovate/tqdm-4.x) (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: findPr(renovate/tqdm-4.x, null, open) (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: getPrList() (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Retrieving PR list (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
INFO: Retrieved Pull Requests (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
"length": 22
DEBUG: branchExists=false (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Branch has 1 upgrade(s) (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: recreateClosed is false (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: findPr(renovate/tqdm-4.x, Update dependency tqdm to v4.36.1, !open) (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: getPrList() (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Found PR #22 (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Found closed PR with current title (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
DEBUG: Closed PR already exists. Skipping branch. (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
"prTitle": "Update dependency tqdm to v4.36.1"
INFO: Merged PR is blocking this branch (repository=XXXXX/XXXXX, dependencies=tqdm, branch=renovate/tqdm-4.x)
"pr": 22

If you rename the title of the previous PR # 22 (e.g. add "old" to it..) then you'll see a replacement PR.

I wasn't able to do that, but I did run it with another test, and it works very well.

For the record, I simply set up a new repo on bitbucket under my bitbucket/renovate-bot account. I then put a single file in it with the following bitbucket-pipeline.yml file. I needed to add two environment variables in settings - USERNAME and PASSWORD. I then set this up to run once a day via the bitbucket scheduler.

This might not be optimal, but it seems to work!

image: alpine

pipelines:
  default:
      - step:
          name: renovate
          services:
              - docker
          caches:
              - docker
          script:
              - docker pull renovate/renovate:slim
              - docker run renovate/renovate:slim --platform=bitbucket --username=$USERNAME --password=$PASSWORD --autodiscover=true --log-level=debug --onboarding=false

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon if no further activity occurs.

Thanks - all working well.

@mccrpad I'm running a command very similar to what you recommended here in the CLI but getting an error. I wanted to ask here before filing a bug. Am I doing something wrong?

renovate --log-level=debug \
    --password=$PASSWORD \
    --username=$USERNAME \
    --platform=bitbucket \
    some-org/some-repo

This generates the error Unsupported platform 'bitbucket' for local preset..

Thanks!

Hi @mikemfleming. Here is the code for our pipeline in bitbucket that runs renovate.

image: alpine

pipelines:
  default:
      - step:
          name: renovate
          services:
              - docker
          caches:
              - docker
          script:
              - docker pull renovate/renovate
              - docker run --env GITHUB_COM_TOKEN=$RENOVATE_TOKEN --env RENOVATE_TOKEN=$RENOVATE_TOKEN -v "$BITBUCKET_CLONE_DIR/config.js:/usr/src/app/config.js" renovate/renovate --platform=bitbucket --username=$USERNAME --password=$PASSWORD --autodiscover=true --log-level=debug --onboarding=false

The variables $RENOVATE_TOKEN, etc are stored in the Bitbucket variables section. The config.js file is:

module.exports = {
    gitAuthor: "renovate-bot <[email protected]>"
}

Does that help?

@mikemfleming Next time please open a new issue and reference the old if applicable. Otherwise you create a lot of noise for people watching old issues.

Local presets are currently not supported for bitbucket cloud, only for gitlab, github and bitbucket server. Feel free to open a fureture request on main repo.

BWT: a better pipeline should be this:

I've preparing some samples, see renovatebot/docker-renovate#99

https://github.com/renovatebot/docker-renovate/blob/docs/bitbucket/docs/bitbucket.md#samples-for-bitbucket-pipelines

@mccrpad I'm running a command very similar to what you recommended here in the CLI but getting an error. I wanted to ask here before filing a bug. Am I doing something wrong?

renovate --log-level=debug \
    --password=$PASSWORD \
    --username=$USERNAME \
    --platform=bitbucket \
    some-org/some-repo

This generates the error Unsupported platform 'bitbucket' for local preset..

Thanks!

@mikemfleming This only causes a WARN, you can ignore that

@mccrpad Oops yes that is totally a warn, looks like I grabbed the wrong lines. Here is the error output:

 INFO: Renovate is exiting with a non-zero code due to the following logged errors
       "loggerErrors": [
         {
           "name": "renovate",
           "level": 50,
           "logContext": "tRNuW66eR",
           "repository": "$NPM_REGISTRY_USER/$NPM_REGISTRY_USER-front-end",
           "err": {
             "task": {
               "commands": [
                 "push",
                 "origin",
                 "renovate/configure:renovate/configure",
                 "--force",
                 "-u",
                 "--no-verify",
                 "--verbose",
                 "--porcelain"
               ],
               "format": "utf-8"
             },
             "message": "Pushing to https://**redacted**@bitbucket.org/$NPM_REGISTRY_USER/$NPM_REGISTRY_USER-front-end.git\nPOST git-receive-pack (566 bytes)\nremote: error: cannot lock ref 'refs/heads/renovate/configure': 'refs/heads/renovate' exists; cannot create 'refs/heads/renovate/configure'        \nerror: failed to push some refs to 'https://**redacted**@bitbucket.org/$NPM_REGISTRY_USER/$NPM_REGISTRY_USER-front-end.git'\n",
             "stack": "Error: Pushing to https://**redacted**@bitbucket.org/$NPM_REGISTRY_USER/$NPM_REGISTRY_USER-front-end.git\nPOST git-receive-pack (566 bytes)\nremote: error: cannot lock ref 'refs/heads/renovate/configure': 'refs/heads/renovate' exists; cannot create 'refs/heads/renovate/configure'        \nerror: failed to push some refs to 'https://**redacted**@bitbucket.org/$NPM_REGISTRY_USER/$NPM_REGISTRY_USER-front-end.git'\n\n    at GitExecutorChain.onFatalException (/usr/local/share/.config/yarn/global/node_modules/simple-git/src/lib/runners/git-executor-chain.js:60:87)\n    at GitExecutorChain.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/simple-git/src/lib/runners/git-executor-chain.js:51:28)\n    at Generator.throw (<anonymous>)\n    at rejected (/usr/local/share/.config/yarn/global/node_modules/simple-git/src/lib/runners/git-executor-chain.js:6:65)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
           },
           "msg": "Error committing files."
         },
         {
           "name": "renovate",
           "level": 50,
           "logContext": "tRNuW66eR",
           "repository": "$NPM_REGISTRY_USER/$NPM_REGISTRY_USER-front-end",
           "err": {
             "task": {
               "concatStdErr": false,
               "format": "utf-8",
               "commands": ["rev-parse", "origin/renovate/configure"]
             },
             "message": "fatal: ambiguous argument 'origin/renovate/configure': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n",
             "stack": "Error: fatal: ambiguous argument 'origin/renovate/configure': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\n    at GitExecutorChain.onFatalException (/usr/local/share/.config/yarn/global/node_modules/simple-git/src/lib/runners/git-executor-chain.js:60:87)\n    at GitExecutorChain.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/simple-git/src/lib/runners/git-executor-chain.js:51:28)\n    at Generator.throw (<anonymous>)\n    at rejected (/usr/local/share/.config/yarn/global/node_modules/simple-git/src/lib/runners/git-executor-chain.js:6:65)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
           },
           "msg": "Repository has unknown error"
         }
       ]

@mikemfleming Please open a new issue!!!

Was this page helpful?
0 / 5 - 0 ratings