Error creating project for repo company/projectname: {"results":[],"status":"error","errors":[{"code":500,"reason":"Failed to setup repo: undefined"}]}
Thanks to a lot of help from this community, I have managed to get Bitbucket projects listing on Strider. Hooray! Now, however, when I try to add a project to Strider from Bitbucket, I get a red toastie with a message along the lines of:
Error creating project for repo company/project: {"results":[],"status":"error","errors":[{"code":500,"reason":"Failed to setup repo: undefined"}]}
This smacks to me of being a MongoDB error to me: why would Strider be trying to create repositories in Bitbucket?
The logs are empty!
Any clues anyone?
Make sure to set the environment variable DEBUG to strider*. Then the logs should (hopefully) have more information.
Hmm. It was set like that, doesn't appear to help though. pm2.log shows the process going up and down quite a lot:
2016-08-08 08:59:01: [PM2][WORKER] Started with refreshing interval: 30000
2016-08-08 08:59:01: [[[[ PM2/God daemon launched ]]]]
2016-08-08 08:59:01: BUS system [READY] on port /home/ubuntu/.pm2/pub.sock
2016-08-08 08:59:01: RPC interface [READY] on port /home/ubuntu/.pm2/rpc.sock
2016-08-08 09:00:01: Starting execution sequence in -fork mode- for app name:strider id:0
2016-08-08 09:00:01: App name:strider id:0 online
2016-08-08 09:11:35: Stopping app:strider id:0
2016-08-08 09:11:35: App [strider] with id [0] and pid [1548], exited with code [0] via signal [SIGINT]
2016-08-08 09:11:35: Starting execution sequence in -fork mode- for app name:strider id:0
2016-08-08 09:11:35: App name:strider id:0 online
2016-08-08 09:11:42: Stopping app:strider id:0
2016-08-08 09:11:42: App [strider] with id [0] and pid [1966], exited with code [0] via signal [SIGINT]
2016-08-08 09:11:42: Starting execution sequence in -fork mode- for app name:strider id:0
2016-08-08 09:11:42: App name:strider id:0 online
but the .pm2/logs folder itself is empty.
Do you get any output when you run Strider directly with node?
I have set the environment variable DEBUG to strider*. Here is my config:
{
"NODE_ENV": "production",
"SERVER_NAME": "http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com",
"STRIDER_CLONE_DEST": "/home/ubuntu/strider-builds/",
"PORT": "3000",
"DEBUG": "strider*"
}
My apps.json looks like this:
{
apps: [
{
"name": "strider",
"script": "bin/strider",
"instances": 1,
"instance_id_env": "STRIDER_APP_INSTANCE",
"exec_mode": "fork",
"env": {
"NODE_ENV": "production",
"SERVER_NAME": "http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:3000",
"PORT": 3000,
"PLUGIN_BITBUCKET_APP_KEY": "xx",
"PLUGIN_BITBUCKET_APP_SECRET": "xxx"
}
}
]
}
The pm2.log file isn't particularly illuminating. It looks a lot like this over and over:
2016-08-14 10:21:27: App [strider] with id [0] and pid [13482], exited with code [0] via signal [SIGINT]
2016-08-14 10:21:27: Starting execution sequence in -fork mode- for app name:strider id:0
2016-08-14 10:21:27: App name:strider id:0 online
strider-error.log is empty, but strider-out.log looks like this:
2016-08-14T10:22:28.669Z - warn: Trying to attach a bitbucket account that's already attached...
2016-08-14T10:31:07.928Z - warn: Trying to attach a bitbucket account that's already attached...
2016-08-14T16:16:45.482Z - warn: Trying to attach a bitbucket account that's already attached...
Do I need to install a later version of strider-bitbucket? I didn't quite grasp the comment on the other board.
I guess you're going to want to set DEBUG in the apps.json. I'm not sure why you have separate configurations. I would assume that the apps.json for pm2 is sufficient to fully configure Strider.
You could try cloning this plugin directly into your node_modules and see if you get more helpful output in that version. I've added some additional logging code in the latest code revision.
I've started a small wiki article with the commands you might need. Please see if this is helpful: https://github.com/Strider-CD/strider/wiki/Debugging
I'm not entirely convinced I understand the reasons I have two configuration files either. This comes from having read two different articles relating to setting up strider! This article talks about setting up strider using .striderrc, whereas this article talks about launching pm2 using apps.json.
In my imagination, I understand the .striderrc to be the general configuration for strider whereas apps.json is specified when running pm2 and indicates which apps to launch. If someone could explain what they actually do I would really appreciate it: I find it perplexing!
Ok, I have enabled logs as recommended and it generates an awful lot of boiler plate logging on startup in .pm2\logs, but specifically the following having tried to pull a repo:
Mon, 15 Aug 2016 09:40:44 GMT strider:ssh Generating SSH key pair...
Mon, 15 Aug 2016 09:40:47 GMT strider:routes:api:repo Setting up repository "company/ap-io" with provider "bit
bucket"...
Mon, 15 Aug 2016 09:40:47 GMT strider:routes:api:repo Setting up repository "company/ap-io" failed! undefined
undefined
Perhaps it's the SSH that's causing the problem? Can I configure strider-bitbucket to use HTTPS instead?
The key pair would be used regardless of the clone protocol. It will be used to register a deploy key for the project on Bitbucket. I can't see why no proper error would be returned, but I would assume that you don't have the proper access rights to register a deployment key for the project.
When I try to create a repository from my Bitbucket account, it works perfectly fine. I would love to be able to reproduce the issue on my end to fix this or make it clearer what is happening here. But I don't know why this happens and I don't have read-only access to any repositories on Bitbucket (if that was the source of the issue).
Now that's something I didn't realise about SSH!
I'm out and about at the moment so can't really check any of this stuff out. But it would seem from the error message, and kinda implied by what you said, that something is trying to create a repo. Would that be on BitBucket or on my local machine where strider is running? In either case I should be able to tweak permissions, right?
.striderrc comes from https://www.npmjs.com/package/rc and isn't really documented for strider (you have to read the code). I recommend using the specified environment variables instead.
@mark-norgate When you add a project, the first thing Strider attempts to do is to register a deployment key. See https://confluence.atlassian.com/bitbucket/use-deployment-keys-294486051.html for more details.
I don't know why this would fail without a proper error message, but something is not right :P
Thanks @oliversalzburg . I have created SSH keys on my Ubuntu box, ensured that the agent is running, imported the keys into Bitbucket, but still I get the same error. I have torn down and restarted using both NODE_ENV=production npm start and pm2 start strider, which both launch strider successfully, but both suffer from the same Bitbucket issue.
Any further ideas? Where might I find details logs? I thought \.pm2 would be the place to look but it's not much use.
Any help greatly appreciated. You can understand that being unable to set up CI is causing issues with my project!
FYI Your bitbucket user (that you setup with strider) needs to have admin access to the repo.
That sounds like it could be a solution @knownasilya. Any chance of some elucidation to this idiot? I kinda need spoon-feeding when it comes to Unix.
I have one user in my strider Bitbucket settings. I'm assuming this is the local Strider account and does not pertain in any way to the Bitbucket account, would that be fair?
How do I give this user permission to do everything admin?
So usually you can go to the account menu, and under bitbucket you will see the bitbucket account you have associated. Then go into your project in bitbucket and login with the same bitbucket account. Once logged in, if you see a cog/gear icon in the lower left of the project page then your bitbucket account has admin access to that bitbucket project.
To be fair, I understood from the error message that is was having difficulty creating the repo locally on the Ubuntu instance. Is that not the case?
I try to give the account with the same name as the local Strider account access, but receive the error that is already has access, even though it's not in the list. Any thoughts?

You are correct, so you probably have a user with admin access in bitbucket. Is there any way you could put a console log here: https://github.com/Strider-CD/strider-bitbucket/blob/master/lib/webapp.js#L132 with console.log(err) and here https://github.com/Strider-CD/strider-bitbucket/blob/master/lib/webapp.js#L146
Hmm. I have to edit a file in Unix? I shall try!
Ok, I did a locate webapp.js and got a lot of hits.
I edited /home/ubuntu/strider/node_modules/strider-bitbucket/lib/webapp.js, but could not locate the text of the second search item you provided. Is this the right file?
I added the console.log(err) to the first location. Where is the console as far as node is concerned?
I have created SSH keys on my Ubuntu box
You're not supposed to generate them yourself. Strider will do that and register the keys in your account.
@mark-norgate just stoping and starting strider, and replicating the issue should print the error in the logs if there is one.