npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ci-build-notifier

v1.2.0

Published

Script for sending messages to Slack with build info from Continuous Integration server like Jenkins

Downloads

22

Readme

NPM

CI Build Slack Notifier

Script is meant to be used with CI (continuous integration) server like Jenkins to notify about build state by sending messages to Slack. It is written as a simple alternative to offical Slack plugin for Jenkins. However, because this project is a simple Node.js script, it can be used with different continuous integration server than Jenkins. Moreover, it can be used without the CI server at all. In that case, it gets info from last GIT commit.

Notifier get build info and current commit from environment variables or last commit from GIT history, combine them with custom message and color and then send message to your Slack webhook. You can see the output below.

Slack screenshot

If you don't want to use Slack, you can show combined info in console, see options below.

Supported CIs

See package env-ci on npm.

Install

Install Node.js environment

This is Node script, so you must have installed Node.js environment. Use one of the options below to install Node.js:

You should be able to check node version with node --version now.

Install CI Build Notifier

Probably you need to install this script globally this way:

$ npm install -g ci-build-notifier

Usage

Now you can send messages by running the command ci-build-notifier with right options listed in table below.

Options

| Shorthand | Option | Description | | ------------- |-------------| -----| | -g | --git-path | GIT root path | | -u | --username | Bot username (optional, "Build notifier" if not set) | | -i | --icon | Bot icon (optional, Jenkins icon if not set) | | -t | --text | Message text | | -a | --node-app-path | Node.js application path as a source for version (optional) | | -v | --app-version | Set version manually (optional) | | | --last-commit | Use last commit from GIT history instead of current commit from CI | | -c | --color | Message hex color (optional) | | | --use-console | Use console output instead of Slack | | -s | --slack-webhook | Slack webhook URL (used only if --use-console is not set) |

Run standalone

ci-build-notifier -a "./app" -g "./" -s "https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ" -c "#AAAAAA" -t "Build started"

Webhook URL is Slack Incoming Webhook, you can read more and create one here.

Run in Jenkins pipeline

pipeline {
  agent any
  stages {
    stage('Send start notification to Slack') {
      steps {
        sh 'ci-build-notifier -a "$WORKSPACE/app" -g "$WORKSPACE" -s "https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ" -c "#AAAAAA" -t "Build started"'
      }
    }
  }
}

Note: Jenkins set environment variable $WORKSPACE to the current build directory.

Build

If you want to modify and build changes, then you must recompile from TypeScript sources with command:

$ npm run build

Pull requests are welcome!

Thanks to

Authors of used libraries, especially author of env-ci.

Author

Lukas Novak

Author

Freelance full-stack software developer based in Olomouc, Czech Republic. I focus on mobile apps with Kotlin and application servers in Node.js. As a hobby, I experiment with voice assistants and build my smart home. See my personal web page (in Czech) or blog on Medium