Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
A Node.js API client for CircleCI
## Installation
npm install circleci --save
Then, in your project require and instantiate the CircleCI client:
var CircleCI = require('circleci');
var ci = new CircleCI({
auth: "my-auth-token"
});
Note that all requests require a valid API token.
Provides information about the signed in user.
ci.getUser().then(function(user){
console.log(user.login); // e.g. your Github username
});
List of all the projects you're following on CircleCI, with build information organized by branch.
ci.getProjects().then(function(projects){
for(var i=0; i < projects.length; i++) {
console.log(projects[i].reponame); // logs the repo name of each project
}
});
Recent builds across all projects. Returns the build summary for each of the last 30 recent builds, ordered by build_num.
ci.getRecentBuilds({ limit: 5, offset: 10 })
.then(function(builds){
for(var i=0; i < builds.length; i++) {
console.log(builds[i].build_num); // logs the build number for each project
}
});
Recent builds for a single project. Returns the build summary for each of the last 30 builds for a single git repo.
ci.getBuilds({ username: "jpstevens", project: "circleci" })
.then(function(builds){
for(var i=0; i < builds.length; i++) {
console.log(builds[i].build_num); // logs the build number for each project
}
});
Recent builds for a single project filtered by a branch name. Returns the build summary for each of the last 30 builds for a single git repo.
ci.getBranchBuilds({ username: "jpstevens", project: "circleci", branch: "master" })
.then(function(builds){
for(var i=0; i < builds.length; i++) {
console.log(builds[i].build_num); // logs the build number for each project
}
});
Full details for a single build. The response includes all of the fields from the build summary. This is also the payload for the notification webhooks, in which case this object is the value to a key named 'payload'.
ci.getBuild({
username: "jpstevens",
project: "circleci",
build_num: 1
}).then(function(build){
console.log(build);
});
Triggers a new build, returns a summary of the build.
ci.startBuild({
username: "jpstevens",
project: "circleci",
branch: "master"
}).then(function(build){
console.log(build);
});
ci.startBuild({
username: "jpstevens",
project: "circleci",
branch: "master",
body:
parallel: null
revision: null
build_parameters:
NODE_ENV: "production"
FOO: "bar"
}).then(function(build){
console.log(build);
});
Cancels the build, returns a summary of the build.
ci.cancelBuild({
username: "jpstevens",
project: "circleci",
build_num: 1
}).then(function(build){
console.log(build);
});
ci.retryBuild({
username: "jpstevens",
project: "circleci",
build_num: 1
}).then(function(build){
console.log(build);
});
List the artifacts produced by a given build.
ci.getBuildArtifacts({
username: "jpstevens",
project: "circleci",
build_num: 1
}).then(function(artifacts){
console.log(artifacts); // logs an array of artifacts
});
Clears the cache for a project
ci.clearBuildCache({
username: "jpstevens",
project: "circleci"
}).then(function(res){
console.log(res.status); // e.g. "build caches deleted"
});
Get the environment variables for a project
ci.getEnvVars({
username: "jpstevens",
project: "circleci"
}).then(function(envvars){
console.log(envvars); // logs an array of environment variables
});
Get a single environment variable for a project by name
ci.getEnvVar({
username: "jpstevens",
project: "circleci",
name: "NPM_TOKEN"
}).then(function(envvar){
console.log(envvar); // logs an object with the environment variable
});
Set a environment variable for a project by name and value
ci.setEnvVar({
username: "jpstevens",
project: "circleci",
body: {
name: "NPM_TOKEN",
value: "123-456-789",
}
}).then(function(envvar){
console.log(envvar); // logs an object with the created environment variable
});
name
and the value
of the environment variable you wish to add to the projectDelete an environment variable from a project by name
ci.deleteEnvVar({
username: "jpstevens",
project: "circleci",
name: "NPM_TOKEN"
}).then(function(envvar){
console.log(envvar); // logs an object with status of the deletion
});
0.1.0 - Initial (stable) release
0.2.0 - Add getBranchBuilds
method
FAQs
A Node.js client for CircleCI
We found that circleci demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.