Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0 buils founds with GitLab #79

Closed
aborderon opened this issue Oct 5, 2017 · 11 comments
Closed

0 buils founds with GitLab #79

aborderon opened this issue Oct 5, 2017 · 11 comments
Labels

Comments

@aborderon
Copy link

Hello,
I have a small problems to run node-build-monitor with GitLab.
I use Docker in production, so I have a Dockerfile and a config.js like :

{
  "monitor": {
    "interval": 30000,
    "numberOfBuilds": 12,
    "latestBuildOnly": false,
    "sortOrder": "date",
    "debug": true
  },
  "services": [
    {
      "name": "GitLab",
      "configuration": {
        "url": "https://gitlab.mycompagny.fr",
        "token": "myGitlabUserToken",
        "additional_query": "&search=mygroup&starred=true",
        "numberOfPipelinesPerProject": 3,
        "slugs": [
          {
            "project": "mygroup/myproject",
            "ref": "master"
          },
          {
            "project": "mygroup/myproject",
            "ref": "develop"
         }
        ]
      }
    }
  ]
}

but I have no results on the website and in my docker logs I get :

$ docker logs --tail all node-build-monitor

warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
9:32:37 AM | Check for builds...
9:32:37 AM | 0 builds found....
node-build-monitor 0.9.24 is listening on port 3000
9:33:07 AM | Check for builds...
9:33:07 AM | 0 builds found....

For information, my Gitlab uses a self-signed certificate.

Thank you for your help ;)

@marcells
Copy link
Owner

@datakurre Do you have any idea what could be wrong with the configuration?

@marcells
Copy link
Owner

@aborderon Could you try to debug the app to see what could be wrong?

@aborderon
Copy link
Author

Yes @marcells , I found the problem, this is the self-signed certificate that I use with Gitlab.

In the request.js, the rejectUnauthorized property to false does not work.

I managed to access my GitLab builds by adding the line just below the exports module of GitLab.js but it is not an acceptable resolution :
module.exports = function () { process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

Do you have a better solution?

@marcells
Copy link
Owner

Hm, that's just an environment variable. Please remove your change from GitLab.js and try the following.

If you use the executable, just set it in your shell before starting the build-monitor. If you use docker, then take a look here how to define an environment variable.

Please let me know, if it worked.

@aborderon
Copy link
Author

Hello, thank you for your answer. I run node-build-monitor with docker with the following command and it work:

docker run -d -p 3000:3000 -e NODE_TLS_REJECT_UNAUTHORIZED=0 --name node-build-monitor node-build-monitor

It would be necessary to add documentation for self signed certificates I think.

I will try to make a pull request to adding docker-compose support. I would take this opportunity to add a configuration with self signed certificates.

Thanks again !

@marcells
Copy link
Owner

Nice to hear! I did update the docs right now. Feel free to make a PR for docker-compose support.

@ElinMagnusson
Copy link

Can I somehow set NODE_TLS_REJECT_UNAUTHORIZED=0 when running the standalone version?

Or can you update the standalone version with this setting?

I tried setting it as a Windows environment variable but I still get 0 builds found...

@marcells
Copy link
Owner

marcells commented Nov 7, 2017

Hm, that should work. At least for the Linux build I tested it.

Did you set it on cmd with set NODE_TLS_REJECT_UNAUTHORIZED=0 before starting node-build-monitor-win.exe from the same cmd session?

I did create a new version right now, which outputs the important environment variables, when you start the monitor.

@ElinMagnusson
Copy link

Hi Marcells, thank for your reply!

Yes I tried that and the variable is printed and set to 0:

Printing environment Variables...
    PORT = unset (Default: 3000)
    NODE_TLS_REJECT_UNAUTHORIZED = 0
node-build-monitor is starting...
07:39:59 | Check for builds...
node-build-monitor 0.9.27 is listening on port 3000...

Now I instead get "check for builds.." and "node-build-monitor is listening on port ... " but there is no message about number of builds?

With version 9.2 I get

07:39:44 | Check for builds...
07:39:44 | 0 builds found....
node-build-monitor 0.9.20 is listening on port 3000

@marcells
Copy link
Owner

marcells commented Nov 8, 2017

So there was a response with 0 builds now. Could it be, that your configuration is wrong?

@kasperschnack
Copy link

kasperschnack commented Jul 22, 2019

Hi I'm having this same problem. The server is running but I can't see in any logs why no builds are fetched. Only output I git from docker-compose logs is this:

docker-compose logs
Attaching to docker_node-build-monitor_1
node-build-monitor_1  | warn:    --minUptime not set. Defaulting to: 1000ms
node-build-monitor_1  | warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
node-build-monitor_1  | error: Could not read .foreverignore file.
node-build-monitor_1  | error: ENOENT: no such file or directory, open '/build-mon/app/.foreverignore'
node-build-monitor_1  | Printing environment Variables...
node-build-monitor_1  |     PORT = unset (Default: 3000)
node-build-monitor_1  |     NODE_TLS_REJECT_UNAUTHORIZED = unset (Default: 1)
node-build-monitor_1  | node-build-monitor is starting...
node-build-monitor_1  | node-build-monitor 0.9.55 is listening on port 3000...

I've tried setting NODE_TLS_REJECT_UNAUTHORIZED: 0 under service: node-build-monitor: environment in docker-compose.with-tfs-proxy.yml. Still nothing happens :/. My config looks like this:

{
  "monitor": {
    "interval": 3000,
    "latestBuildOnly": true,
    "sortOrder": "date",
    "debug": false
  },
  "services": [
    {
      "name": "GitLab",
      "configuration": {
        "url": "<company-Gitlab-url>",
        "token": "<api-token>",
        "numberOfPipelinesPerProject": 3,
        "pipeline": {
          "status": ["running", "pending", "success", "failed", "canceled", "skipped"]
        }
      }
    }
  ]
}

Any idea what I could be doing wrong?

Ok it seems i was using the wrong kind of token (readonly before - now api). No builds appear on the server but at least now i get an error:

docker [master●] % docker-compose logs
Attaching to docker_node-build-monitor_1
node-build-monitor_1  | warn:    --minUptime not set. Defaulting to: 1000ms
node-build-monitor_1  | warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
node-build-monitor_1  | error: Could not read .foreverignore file.
node-build-monitor_1  | error: ENOENT: no such file or directory, open '/build-mon/app/.foreverignore'
node-build-monitor_1  | Printing environment Variables...
node-build-monitor_1  |     PORT = unset (Default: 3000)
node-build-monitor_1  |     NODE_TLS_REJECT_UNAUTHORIZED = unset (Default: 1)
node-build-monitor_1  | node-build-monitor is starting...
node-build-monitor_1  | node-build-monitor 0.9.55 is listening on port 3000...
node-build-monitor_1  | /build-mon/app/services/GitLab.js:46
node-build-monitor_1  |                     pipelines = pipelines.filter(function(pipeline) {
node-build-monitor_1  |                                           ^
node-build-monitor_1  |
node-build-monitor_1  | TypeError: pipelines.filter is not a function
node-build-monitor_1  |     at /build-mon/app/services/GitLab.js:46:43
node-build-monitor_1  |     at Request._callback (/build-mon/app/services/GitLab.js:36:17)
node-build-monitor_1  |     at Request.self.callback (/build-mon/node_modules/request/request.js:185:22)
node-build-monitor_1  |     at emitTwo (events.js:106:13)
node-build-monitor_1  |     at Request.emit (events.js:194:7)
node-build-monitor_1  |     at Request.<anonymous> (/build-mon/node_modules/request/request.js:1161:10)
node-build-monitor_1  |     at emitOne (events.js:96:13)
node-build-monitor_1  |     at Request.emit (events.js:191:7)
node-build-monitor_1  |     at IncomingMessage.<anonymous> (/build-mon/node_modules/request/request.js:1083:12)
node-build-monitor_1  |     at Object.onceWrapper (events.js:293:19)
node-build-monitor_1  | error: Forever detected script exited with code: 1
node-build-monitor_1  | error: Script restart attempt #1
node-build-monitor_1  | Printing environment Variables...
node-build-monitor_1  |     PORT = unset (Default: 3000)
node-build-monitor_1  |     NODE_TLS_REJECT_UNAUTHORIZED = unset (Default: 1)
node-build-monitor_1  | node-build-monitor is starting...
node-build-monitor_1  | node-build-monitor 0.9.55 is listening on port 3000...
node-build-monitor_1  | /build-mon/app/services/GitLab.js:46
node-build-monitor_1  |                     pipelines = pipelines.filter(function(pipeline) {
node-build-monitor_1  |                                           ^
node-build-monitor_1  |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants