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

jenkins-build-pipeline

v0.2.0

Published

Promise-based API for running a pipeline of multiple dependent jobs

Downloads

3

Readme

jenkins-build-pipeline

Get it on npm

Promise-based API for starting a pipeline of subsequent jobs

This implementation uses polling of /job/<jobName>/lastBuild/api/json Jenkins HTTP API, without using queue API (for some reason, my company's Jenkins fork does not support queue API... don't ask).

Installation

npm install --save jenkins-build-pipeline

Usage

var JenkinsBuildPipeline = require('jenkins-build-pipeline');

JenkinsBuildPipeline.startBuildPipeline([
  'job1', 'job2'
])
.then(function onPipelineSuccess(buildInfo) {
  // buildInfo is info about the build number of the last build in the pipeline
  console.log(buildInfo.buildNumber) // String like '123'
})
.catch(function onPipelineFailure(buildInfo) {
  if (buildInfo.isTimeoutWhileOngoing) {
    msg = 'Build taking too long, giving up on following it. Check status on ' + buildInfo.url;
  } else if (buildInfo.isTimeoutWhileQueued) {
    msg = 'Build queued for too long, giving up on following it. Check status on ' + buildInfo.url;
  } else if (buildInfo.isSuccess === false) {
    msg = 'Build failed! Check status on ' + buildInfo.url;
  } else {
    msg = 'Unexpected error during the pipeline execution or inside jenkins-build-pipeline code!';
  }
  console.error(msg);
});

Then in the console

JENKINS_USER=myjenkinsuser JENKINS_PASSWORD=myjenkinspassword JENKINS_HOST=example.org node my-jenkins-pipeline.js

Note: job name in the examples is a part of your Jenkins job URL after the first job/

For example, if you use nested folders on Jenkins and your URL is /job/myproject/job/releases/job/master, then you should pass myproject/job/releases/job/master as job name.

Config

You can configure polling interval, and when to report a timeout while build is still queued or ongoing.

You should set this value to an abnormally high time that should not happen in normal cases. For example if your builds typically take 6-8 minutes, set it to e.g. 15 minutes.

Note that the build might be still queued or ongoing just fine, but maybe your build server is slow, or there's a bug in pipeline code. Anyway, if build time significantly surpasses the timeout value, some intervention is needed.

For now the build is stopped and a promise rejection happens when hitting the timeout.

This is how you override the defaults:

var JenkinsBuildPipeline = require('jenkins-build-pipeline');

JenkinsBuildPipeline.POLLING_INTERVAL_SECONDS = 15;
JenkinsBuildPipeline.BUILD_NOT_YET_STARTED_DIFF_SECONDS = JenkinsBuildPipeline.POLLING_INTERVAL_SECONDS * 3;
JenkinsBuildPipeline.QUEUED_TIMEOUT_SECONDS = 5 * 60;
JenkinsBuildPipeline.ONGOING_TIMEOUT_SECONDS = 30 * 60;

JenkinsBuildPipeline.startBuildPipeline(...)

Debugging

DEBUG=jenkins-build-pipeline node my-jenkins-pipeline.js

See more at https://github.com/visionmedia/debug

Node version compat

Tested on nodejs 4.x.