Skip to content

A Build Monitor written in Node.js, which supports several build services and can be easily extended.

License

Notifications You must be signed in to change notification settings

rgetz/node-build-monitor

 
 

Repository files navigation

Build Status Code Climate Dependency Status Known Vulnerabilities

node-build-monitor

A Build Monitor written in Node.js, which supports several build services. It can be easily extended to support new services. You can mix different services as you like and you'll always see the newest builds in its responsive and themable web frontend automatically. And finally, everything is prepared to run as a Docker container.

Here's a demo: http://builds.mspi.es (other themes)
(automatically deployed from this repository with Docker Cloud as a Docker container to the Microsoft Azure Cloud)

Screenshot

Supported services

Feel free to make a Fork of this repository and add another service.

Jump to the configuration documentation and see how the services are configured.

Quickstart

You have four options:

Configuration

The build monitor configuration can be placed in one of the following locations:

  1. %HomeDirectory%/node-build-monitor-config.json
  2. %PathOfExecutable%/config.json (only for the standalone version)
  3. app/config.json
{
  "monitor": {
    "interval": 30000,
    "numberOfBuilds": 12,
    "latestBuildOnly": false,
    "sortOrder": "date",
    "errorsFirst": false,
    "expandEnvironmentVariables": false,
    "debug": true
  },
  "services": [
    {
      "name": "Travis",
      "configuration": {
        "slug": "node-build-monitor"
      }
    },
    {
      "name": "Travis",
      "configuration": {
        "slug": "marcells/bloggy",
        "latestBuildOnly": true
      }
    }
  ]
}

In the monitor section you can set up some general settings:

Setting Description
interval The update interval (in milliseconds)
numberOfBuilds The number of builds, which will be read and displayed in the web frontend (ignored if latestBuildOnly is enabled)
latestBuildOnly Will only retrieve single latest build from each service configuration. This setting can be overwritten in each service configuration.
sortOrder The sort order for buils, options : project, date
errorsFirst Errors should be before success elements, apply sortOrder after that
expandEnvironmentVariables Tries to expand root service configuration properties from environment variables (e.g.: "${MY_PASSWORD}" will look for an environment variable MY_PASSWORD and will use that)
debug Enable or disable some debug output on the console. Useful, if you're hunting an issue in a plugin or its configuration.

The services section accepts an array, each describing a single build service configuration (you are allowed to mix different services):

  • the name setting refers to the used service
  • the configuration setting refers to its configuration, which may differ from each service (see below)

Travis CI

Supports the Travis CI build service.

{
  "name": "Travis",
  "configuration": {
    "slug": "marcells/node-build-monitor"
  }
}
Setting Description
slug The name of the build (usually your GitHub user name and the project name)
url The Travis CI server (travis-ci.org, travis-ci.com, travis.enterprise_name.com). Defaults to travis-ci.org.
token The Travis access token, to access your private builds (can be found on your Accounts page. If this does not work then you must use the access token you get by executing shell commands. More information can be found at https://blog.travis-ci.com/2013-01-28-token-token-token).
is_enterprise Set this value to true if you plan to use Travis CI enterprise. Default to false.

Jenkins

Supports the Jenkins build service. The service can operate in single-job or single-view mode. In single-job mode, the builds of a selected Jenkins job are shown. In single-view mode, the builds of all the jobs in a given Jenkins view are shown. In both modes, one can limit the maximum number of recent builds per job.

{
  "name": "Jenkins",
  "configuration": {
    "url": "http://jenkins-server:8080",
    "username": "jenkins_username",
    "password": "jenkins_password",
    "job": "JenkinsJobName",
    "numberOfBuildsPerJob": 3,
    "options": {
      "strictSSL": false
    }
  }
}
Setting Description
url The url to the Jenkins server
username Your Jenkins user name
password Your Jenkins password
job The name of the Jenkins job whose builds are to be shown in single-job mode. Takes precedence over view if both are given.
view The name of the Jenkins view whose jobs and builds are to be shown in single-view mode. Optional.
options The request options.
Refer to request module options for possible values
numberOfBuildsPerJob Limit the number of builds fetched for each job. Optional, defaults to no limitation.

TeamCity

Supports the TeamCity build service.

{
  "name": "TeamCity",
  "configuration": {
    "url": "http://teamcity_username:teamcity_password@teamcity-server:8111",
    "buildConfigurationId": "TeamCityProject_TeamCityBuildConfiguration",
    "branch": "master",
    "authentication": "ntlm",
    "username": "teamcity_username",
    "password": "teamcity_password",
    "useGuest": true,
    "reportFailedToStart": true
  }
}
Setting Description
url The url to the TeamCity server (including the credentials without a trailing backslash, if not the guest user is used).
buildConfigurationId The id of the TeamCity build configuration
branch The name of branch that needs to be monitored. Will monitor all branches if not specified.
authentication This option is only required if using 'ntlm' other option have no meaning
username Your TeamCity user name (if required)
password Your TeamCity password (if required)
useGuest Uses the guest user (if required)
reportFailedToStart Causes "Failed to Start" builds to be reported as build failures.

Azure DevOps and Team Foundation Server Builds

Supports Azure Pipelines, the Azure DevOps and Team Foundation Server build service.

{
  "name": "Tfs",
  "configuration": {
    "url": "https://{youraccount}.visualstudio.com or http://tfs-server:8080/tfs",
    "collection": "DefaultCollection",
    "project": "projectname",
    "username": "username",
    "pat": "personalaccesstoken",
    "queryparams": "&branchName=refs/heads/master&definitions=4,5,6,7&maxBuildsPerDefinition=1",
    "includeQueued": false,
    "showBuildStep": false
  }
}
Setting Description
url Url to your Azure DevOps account (https://dev.azure.com/youraccount/) or TFS server (http://tfs-server:8080/tfs)
collection Collection name. Defaults to DefaultCollection.
project Team project ID or name
username Username used to login (if it's a domain user, ensure to escape the backslash in the configuration: "domain\\username")
pat Personal Access Token with access to builds (TFS 2015 users should be able to use the password for the given user)
queryparams Any query params that REST API accepts, more info: https://docs.microsoft.com/en-us/rest/api/vsts/build/
includeQueued Set to true, if queued builds should be shown on the monitor. Defaults to false.
showBuildStep Set to true, to add the current step/stage to the text show for the status. Defaults to false.

Note:

  • Create a peronal access token with access to read builds.
  • The url formed is of the following format: https://{instance}/{collection}/{project}/_apis/build/builds?api-version=2.0[queryparams]
  • Please note that all the configuration fields are mandatory. If a field is not required like queryparams, please provide empty string in the configuration.

Azure DevOps and Team Foundation Server Releases

Supports Azure Piplines, the Azure DevOps and Team Foundation Server (Releases) release service.

{
  "name": "TfsRelease",
  "configuration": {
    "protocol": "protocol",
    "project": "projectname",
    "instance": "instance",
    "username": "username",
    "pat": "personalaccesstoken",
    "queryparams" : "&$top=10",
    "groupbyrelease": false,
    "apiVersion": "4.1-preview"
  }
}
Setting Description
protocol Use HTTP or HTTPS will default to HTTPS if it is not set
project Team project ID or name
instance Azure DevOps account without https:// (dev.azure.com/youraccount/yourcollection) or TFS server (tfs-server:8080/tfs/yourcollection) including collection.
username Username used to login
pat Personal Access Token with access to releases
queryparams Any query params that REST API accepts, more info: VSTS Rest Uri parameters
groupbyrelease Group builds by same release id. Defaults to false.
apiVersion The API version to target. Defaults to 4.1-preview. Allowed values are: 3.2-preview 4.1-preview

Note: Create a personal access token with access to read builds.

  • The url formed is of the following format: https://{instance}/{project}/_apis/release/deployments?api-version={apiVersion}[queryparams]
  • Please note that all the configuration fields are mandatory. If a field is not required like queryparams, please provide empty string in the configuration.

Team Foundation Server 2013 and lower (on-premise)

Supports an on-premise Microsoft Team Foundation Server via the tfs-proxy bridge.

{
  "name": "TfsProxy",
  "configuration": {
    "tfsProxyUrl": "http://tfs-proxy:4567/builds",
    "url": "http://tfs-server:8080/tfs/DefaultCollection",
    "username": "domain\\buildadmin",
    "password": "buildadmin_password"
  }
}
Setting Description
tfsProxyUrl The url to the tfs-proxy. If you use Docker to run node-build-monitor and tfs-proxy, this setting can be omitted (see details below in the Docker section).
url The full Team Collection Url, which builds are displayed (selecting single team projects or build definitions is not supported currently)
authentication This option is only required if using 'ntlm' other option have no meaning
username User with permission to query build details
password The password for the user

Team Foundation Server 2015/2017 (on-premise)

Supports an on-premise Microsoft Team Foundation Server 2015/2017 (and later).

{
  "name": "Tfs2015",
  "configuration": {
    "url": "http://tfs-server:8080/tfs/DefaultCollection/TeamProject",
    "username": "domain\\buildadmin",
    "password": "buildadmin_password"
  }
}
Setting Description
url The full Team Collection Url, including the TeamProject, which builds are displayed
authentication This option is only required if using 'ntlm' other option have no meaning
username User with permission to query build details
password The password for the user (if using TFS 2017 see notes below)

Important: For TFS 2017 you have to create a personal access token. It only needs the permission to read builds. Please use your username and the generated token as the password.

GitLab (on-premise, beta)

Supports an on-premise GitLab Community Edition/Enterprise Edition with built-in CI server. Also supports hosted gitlab.

{
  "name": "GitLab",
  "configuration": {
    "url": "http://gitlab.example.com:8080",
    "token": "secret_user_token",
    "additional_query": "&search=gitlab-org&starred=true",
    "numberOfPipelinesPerProject": 3,
    "pipeline": {
      "status": ["running", "pending", "success", "failed", "canceled", "skipped"]
    },
    "slugs": [
      {
        "project": "gitlab-org/gitlab-ci-multi-runner",
        "ref": "master"
      }
    ]
  }
}
Setting Description
url GitLab server http(s) address string
token Secret token string for the existing user to be used to authenticate against GitLab REST API
slugs List of project slugs to display and check for builds. Defaults to */* for all projects you have access to. Use /* when specifying group slug to include projects only from current group and /** to also include subgroups. Optional 'ref' attribute can be used to specify the branch.
intervals How often (in integer of milliseconds) ...
additional_query Add additional query parameters so not too many projects are fetched.
numberOfPipelinesPerProject Limit the number of pipelines fetched for each project. Optional, defaults to no limitation.

Because API V4 returns all internal and public projects by default, you propably want to set additional_query as well. Good choices could be &owned=true or &membership=true. If you want to filter the pipeline status you'll need to set pipeline.status otherwise it will show every status.

BuddyBuild

Supports BuddyBuild build service

{
  "name": "BuddyBuild",
  "configuration": {
    "project_name": "Android",
    "app_id": "Your-App-ID",
    "url": "https://api.buddybuild.com/v1/apps",
    "access_token": "Your-Access-Token",
    "build_id": "",
    "branch": "develop"
  }
}
Setting Description
project_name Label of the project name, normally IOS or Android. Required only, if your app_id is provided.
app_id BuddyBuild Application ID. Leave empty to get all the builds for your user token.
url BuddyBuild Build Query url
access_token Secret token string for the existing user to be used to authenticate against BuddyBuild REST API (if BUILDBUDDY_ACCESS_TOKEN environment variable is set, this setting is overwritten)
build_id Leave empty to get the latest build. Provide the build ID to query that specific build.
branch Name of the branch

Bamboo

Supports Bamboo build service

{
  "name": "Bamboo",
  "configuration": {
    "url": "http://yourbamboo.com",
    "planKey": "Plan-Key",
    "username": "user",
    "password": "pass",
    "includeAllStates": true,
    "latestBuildPerBuildPlanOnly": true
  }
}
Setting Description
url URL of the Bamboo host
planKey Plan-Key
username HTTP-Basic-Auth Username (optional)
password HTTP-Basic-Auth Password (optional)
includeAllStates include in-progress/stopped state (optional)
latestBuildPerBuildPlanOnly request only latest build per build plan. The behavior is similar to monitor.latestBuildOnly but this setting limits number of results returned from Bamboo server instead of retrieving all builds and limiting from the application (optional)

BambooDeploy

Supports BambooDeploy deployment service

{
  "name": "BambooDeploy",
  "configuration": {
    "url": "http://yourbamboo.com",
    "planKey": "Plan-Key",
    "username": "user",
    "password": "pass",
    "includeAllStates": true,
    "latestBuildPerBuildPlanOnly": true,
    "environmentName": "dev",
    "projectId": 123
  }
}
Setting Description
url URL of the Bamboo host
planKey Plan-Key
username HTTP-Basic-Auth Username (optional)
password HTTP-Basic-Auth Password (optional)
includeAllStates include in-progress/stopped state (optional)
latestBuildPerBuildPlanOnly request only latest build per build plan. The behavior is similar to monitor.latestBuildOnly but this setting limits number of results returned from Bamboo server instead of retrieving all builds and limiting from the application (optional)
environmentName Environment Name of the deployment region (dev, prod etc)
projectId ProjectId for the PlanKey/Project

Bitbucket Pipelines

Supports Bitbucket Pipelines build service.

In order to monitor a Bitbucket pipeline, one has to create an app-password by navigating to https://bitbucket.org/account/user/<username>/app-passwords

Once "Create app password" has been clicked, one has to ensure that the "read pipelines" box has been checked. Once this box has been checked, click "create" and an AppPassword will be returned that has to be copied to the config.json:

{
  "name": "BitbucketPipelines",
  "configuration": {
    "apiKey": "key",
    "username": "username",
    "slug": "slug",
    "teamname": "teamname"
  }
}
Setting Description
apiKey The API key on the Bitbucket settings
username The account username
slug The name of the project
teamname The team owner of the project. Only use this if the team is the project owner.

Buildkite

Supports Buildkite build service

{
  "name": "Buildkite",
  "configuration": {
    "orgSlug": "your-organisation-slug",
    "teamSlug": "everyone"
  }
}
Setting Description
orgSlug Organization slug, visible in the url when on the pipelines page (e.g https://buildkite.com/<your-organisation-slug>)
teamSlug An team slug to filter the pipelines on, set to everyone for all pipelines
BUILDKITE_TOKEN An ENVIRONMENT VARIABLE with your access token. See: graphql-api for instructions on generating your token.

Bitrise

Supports the Bitrise build service.

{
  "name": "Bitrise",
  "configuration": {
    "slug": "<ID OF YOUR APPLICATION>",
    "token": "<YOUR PERSONAL API TOKEN>"
  }
}
Setting Description
slug APP ID of your application
url Build / API server url, defaults to bitrise.io
token API access token (can be generated in account settings)
apiVersion API version to use, defaults to v0.1

CCTray

Supports CCTray format. CCTray is part of CruiseControl.NET.

{
  "name": "CCTray",
  "configuration": {
    "url": "<URL FOR CCTRAY>"
  }
}
Setting Description
url Url of CCTray feed.

Shippable

Supports the Shippable build service.

{
  "name": "Shippable",
  "configuration": {
    "url": "https://api.shippable.com",
    "token": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeee",
    "projects": "123456789012345678901234,098765432109876543210987,...",
    "branch": "master",
    "limit": 12
  }
}
Setting Description
url Shippable API URL (default https://api.shippable.com)
token Shippable API token (can be generated under Account settings)
projects Comma separated list of Shippable project IDs to be used
branch The branch to be monitored (all branches if not specified)
limit Limit the number of returned results from the Shippable API

PRTG

Supports the PRTG monitoring service.

{
  "name": "PRTG",
  "configuration": {
    "url": "https://myprtg.myserver",
    "sensorId": "1234",
    "username": "username",
    "passhash": "123456789"
  }
}
Setting Description
url PRTG Service URL (e.g. https://prtg.mydomain.local)
sensorId Sensor Identifier
username Name of the user
passhash Passhash of the user (Visible under Configuration - My Account)

CircleCI

Supports the CircleCI service

{
  "name": "CircleCI",
  "configuration": {
    "debug": false,
    "token": "somePersonalToken",
    "vcs": "bitbucket",
    "username": "marcells",
    "project": "node-build-monitor",
    "branch": "master",
    "groupByWorkflow": true
  }
}
Setting Description
debug Should the debug be enabled
token A CircleCI personal token
vcs The VCS type of the project (bitbucket
username Project username or team name
project Project name (usually your repository)
branch Optional. A specific branch to display exclusively.
groupByWorkflow Optional. Groups jobs by workflow. Default false.

Drone

Supports the Drone build service (version 1.0 minimum)

{
  "name": "Drone",
  "configuration": {
    "debug": false,
    "url": "drone.company.io",
    "token": "s0meDr0neMachineToken",
    "slug": "marcells/node-build-monitor"
  }
}
Setting Description
slug The name of the build (usually your GitHub user name and the project name)
url The Drone CI server (cloud.drone.io, ci.company.io...)..
token The Drone access token, to access the builds. We recommand generating a machine token using the Drone CLI command drone user add build-monitor --machine.
branch Set this value to filter the builds from a specific branch. (ie. master)
event Set this value to filter the builds from a specific event. (ie. push, promote, pull_request)

Run the standalone version (easiest way)

  1. Download the latest release for Linux (x64), MacOS (x64) or Windows (x64)
  2. For MacOS and Linux you need to set the execute permission to run it
    • MacOS: chmod +x node-build-monitor-macos
    • Linux: chmod +x node-build-monitor-linux
  3. Place a file config.json next to the executable (see the description of the file in the configuration section above)
  4. Run the executable
  5. Open your browser and navigate to http://localhost:3000 (switch to fullscreen for the best experience)

Run it manually (during development)

  1. Pull the repository
  2. Run npm install
  3. Place a file config.json in the app folder (see the description of the file in the configuration section above)
  4. If you connect to services, which are using self signed certificates, then you have to set the environment variableNODE_TLS_REJECT_UNAUTHORIZED=0. (More Info)
  5. Run the build monitor with node app/app.js
  6. Open your browser and navigate to http://localhost:3000 (switch to fullscreen for the best experience)

Run grunt to execute the tests and check the source code with JSHint.

Run it with Docker Compose (in production)

You can try out or install the build monitor with Docker Compose easily.

TL;DR: Go to the docker directory, rename the file config.example.json to config.json and edit with your configuration or create config.json file directly. Then run the following commands, which you need.

Below, each commands is explained in detail.

1. Create configuration and set up the build monitor

Place a file config.json next to the docker-compose.*.yml and configure the services:

{
  "monitor": {
    "interval": 30000,
    "numberOfBuilds": 12,
    "latestBuildOnly": false,
    "sortOrder": "date",
    "debug": true
  },
  "services": [
    {
      "name": "Travis",
      "configuration": {
        "slug": "marcells/bloggy"
      }
    },
    {
      "name": "Travis",
      "configuration": {
        "slug": "marcells/node-build-monitor"
      }
    }
  ]
}

See the description of this file in the configuration section above.

2. Build your custom build monitor image and run the container

Build your custom node-build-monitor docker image. This will also include your configuration from the previous step. Afterwards the container is started.

a. Without tfs-proxy

Installing and running node-build-monitor in a docker container for use on the same machine is simple with the following commands:

Run docker-compose from your custom docker-compose.yml:

docker-compose build --pull
docker-compose up -d
b. With tfs-proxy

If you want to get access to the tfs-proxy, then you need a slighly different command, which allows the build monitor container to access the tfs-proxy container.

Run docker-compose from your custom docker-compose.with-tfs-proxy.yml:

docker-compose -f docker-compose.with-tfs-proxy.yml build --pull
docker-compose -f docker-compose.with-tfs-proxy.yml up -d

Ensure that you omit the tfsProxyUrl setting in your config.json, so that it can be determined automatically. Here you'll get more information about container linking.

c. With self-signed-certs

If you connect to services which are using self signed certificates, run docker-compose from your custom docker-compose.with-self-signed-certs.yml:

docker-compose -f docker-compose.with-self-signed-certs.yml build --pull
docker-compose -f docker-compose.with-self-signed-certs.yml up -d

3. Access it with your browser

Now open your browser and navigate to http://localhost:3000 to see your running or finished builds. Switch to fullscreen for the best experience.

(4. Access logs)

You can take a look at the logs of the build monitor by using this command:

docker-compose logs

Run it in Kubernetes as a helm chart

You can use the helm chart to deploy node-build-monitor in your kubernetes cluster.

TL;DR: Go to the charts directory, and deploy it to your cluster with helm install . --name build-monitor. To set the configuration you need to modify the values.yaml file. See Readme in chart folder for more informations.

Theming support

Here you can check out the existing themes. Feel free to add your own and make a pull request. It can be done very easy.

Theme Description Preview
default Works best on bigger screens with a high resolution Demo
lowres Works best on screens with a lower resolution Demo
list Displays the builds as a list, instead of tiles Demo
lingo Describes the build status in form of a hand-written sentence Demo

You can switch the themes by the url parameter theme. e.g.: http://localhost:3000?theme=list

Creating a new theme

If you want to create a new theme, you simply have to create one template file and one stylesheet in the following paths.

  • Stylesheet: app/public/stylesheets/themes/[name of theme]/style.css (you can place dependent css files in this folder)
  • Template: app/public/templates/themes/[name of theme]/.html

Please use a unique class prefix like [name of theme]-theme for your css, so that we do not run into any conflicts with other themes.

A list with the name builds with Knockout.js ViewModels BuildViewModel will be bound to the template. Knockout.js has a very low learning curve and provides a powerful data-binding mechanism.

Just check out the other themes to get sample code. It's quite easy to create new themes.

Additional: Raspberry Pi Configuration

Here are some useful links, how to run the build monitor frontend on a Raspberry Pi.

This sample script can be used in a cronjob to automatically send your screen to sleep mode in the evening and wake it up in the morning.

#!/bin/bash

if [ $1 = 'on' ]; then
  tvservice -p;
  fbset -depth 8;
  fbset -depth 16;
  chvt 6;
  chvt 7;
  echo 'Switched Screen ON!'
fi

if [ $1 = 'off' ]; then
  tvservice -o
  echo 'Switched Screen OFF!'
fi

License

The MIT License (MIT)

Copyright (c) 2017 Marcell Spies (@marcells | http://mspi.es)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A Build Monitor written in Node.js, which supports several build services and can be easily extended.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 72.1%
  • HTML 17.8%
  • CSS 9.4%
  • Other 0.7%