Models
Screwdriver Models
Install / Use
/learn @screwdriver-cd/ModelsREADME
Screwdriver Models
[![Version][npm-image]][npm-url] ![Downloads][downloads-image] [![Build Status][status-image]][status-url] [![Open Issues][issues-image]][issues-url] ![License][license-image]
Screwdriver models
Usage
Asynchronous methods return promises.
npm install screwdriver-models
Pipeline Factory
Search
'use strict';
const Model = require('screwdriver-models');
const factory = Model.PipelineFactory.getInstance({
datastore,
scm
});
const config = {
params: {
scmUri: 'github.com:12345:banana'
},
paginate {
page: 2,
count: 3
},
sort: 'ascending',
sortBy: 'scmRepo.name'
}
factory.list(config).then(pipelines => {
// Do stuff with list of pipelines
});
| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| config | Object | Config Object |
| config.paginate.page | Number | The page for pagination |
| config.paginate.count | Number | The count for pagination |
| config.params | Object | Fields to search on |
| config.raw | Boolean | Whether to return raw data or not |
| config.search | Object | Search parameters |
| config.search.field | String or Array | Search field(s) (e.g.: jobName) |
| config.search.keyword | String | Search keyword (e.g.: %PR-%) |
| config.sort | String | Order to sort by (ascending or descending) |
| config.sortBy | String | Key to sort by (default id) |
Create
factory.create(config).then(model => {
// do stuff with pipeline model
});
| Parameter | Type | Required | Description | | :------------- | :---- | :---- | :-------------| | config | Object | Yes | Configuration Object | | config.admins | Object | Yes | Admins for this pipeline, e.g { batman: true } | | config.scmUri | String | Yes | Source Code URI for the application | | config.scmContext | String | Yes | Scm context to which user belongs |
Get
Get a pipeline based on id. Can pass the generatedId for the pipeline, or the unique keys for the model, and the id will be determined automatically.
factory.get(id).then(model => {
// do stuff with pipeline model
});
factory.get({ scmUri }).then(model => {
// do stuff with pipeline model
});
| Parameter | Type | Description | | :------------- | :---- | :-------------| | id | Number | The unique ID for the pipeline | | config.scmUri | String | Source Code URI for the application |
Pipeline Model
Update
Update a specific pipeline model
model.update()
Example:
'use strict';
const Model = require('screwdriver-models');
const factory = Model.PipelineFactory.getInstance({
datastore,
scm
});
const scmUri = 'github.com:12345:master';
factory.get({ scmUri }).then(model => {
model.scmUri = 'github.com:12345:foo';
return model.update();
})
Add Screwdriver webhook
Attach Screwdriver webhook to the pipeline's repository
model.addWebhook(webhookUrl)
| Parameter | Type | Description | | :------------- | :---- | :--------| | webhookUrl | String | The webhook url to be added |
Sync
Sync the pipeline. Look up the configuration in the repo to create and delete jobs if necessary.
model.sync()
Get Configuration
Get the screwdriver configuration for the pipeline at the given ref
model.getConfiguration(config)
| Parameter | Type | Required | Description | | :------------- | :---- | :--- | :--------| | ref | String | No | Reference to the branch or PR |
Get Jobs
Return a list of jobs that belong to this pipeline
model.getJobs(config)
| Parameter | Type | Required | Default | Description | | :------------- | :---- | :--- | :--- | :-------------| | config | Object | No | | Configuration Object | | config.params | Object | No | | Fields to search on | | config.paginate.page | Number | No | | The page for pagination | | config.paginate.count | Number | No | | The count for pagination |
Get Events
Return a list of events that belong to this pipeline
model.getEvents(config)
| Parameter | Type | Required | Default | Description |
| :------------- | :---- | :--- | :--- | :-------------|
| config | Object | No | | Config Object |
| config.type | Number | No | pipeline | Type of event: pipeline or pr |
| config.sort | String | No | descending| Order to sort by (ascending or descending) |
Tokens
Get the pipeline's access tokens
model.tokens
.then((tokens) => {
// do stuff with tokens
});
Get Event Metrics
Get all the event durations for this pipeline within time range
model.getMetrics()
.then((metrics) => {
// do stuff with metrics
});
Job Factory
Search
'use strict';
const Model = require('screwdriver-models');
const factory = Model.JobFactory.getInstance({
datastore
});
const config = {
params: {
pipelineId: 1
},
paginate {
page: 2,
count: 3
}
}
factory.list(config).then(jobs => {
// Do stuff with list of jobs
});
| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.paginate.page | Number | The page for pagination | | config.paginate.count | Number | The count for pagination | | config.params | Object | fields to search on |
Create
factory.create(config).then(model => {
// do stuff with job model
});
| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.pipelineId | Number | The pipelineId that the job belongs to | | config.name | String | The name of the job |
Get
Get a job based on id. Can pass the generatedId for the job, or the unique keys for the model, and the id will be determined automatically.
factory.get(id).then(model => {
// do stuff with job model
});
factory.get({ pipelineId, name }).then(model => {
// do stuff with job model
});
| Parameter | Type | Description | | :------------- | :---- | :-------------| | id | Number | The unique ID for the job | | config.pipelineId | Number | Id of the pipeline the job is associated with | | config.name | String | Name of the job |
Job Model
'use strict';
const Model = require('screwdriver-models');
const factory = Model.JobFactory.getInstance({
datastore
});
factory.get(id).then(model => {
model.name = 'hello';
return model.update();
});
Update
Update a job
model.update()
Get builds
Return builds that belong to this job
model.getBuilds(config)
| Parameter | Type | Required | Default | Description |
| :------------- | :---- | :--- | :---- | :-------------|
| config | Object | No | | Configuration Object |
| config.sort | String | No | descending | ascending or descending |
Get running builds
Return all running builds that belong to this jobId
model.getRunningBuilds()
Get Build Metrics
Get all the build durations for this job within time range
model.getMetrics()
.then((metrics) => {
// do stuff with metrics
});
Build Factory
Search
'use strict';
const Model = require('screwdriver-models');
const factory = Model.BuildFactory.getInstance({
datastore,
scm,
executor,
uiUri
});
const config = {
params: {
jobId: 4
},
paginate {
page: 2,
count: 3
}
}
factory.list(config).then(builds => {
// Do stuff with list of builds
});
| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Config Object | | config.paginate.page | Number | The page for pagination | | config.paginate.count | Number | The count for pagination | | config.params | Object | fields to search on |
Create
factory.create(config).then(model => {
// do stuff with build model
});
| Parameter | Type | Required | Description | | :------------- | :---- | :-------------| :-------------| | config | Object | Yes | Configuration Object | | config.apiUri | String | Yes | URI back to the API | | config.tokenGen | Function | Yes | Generator for building tokens | | config.username | String | Yes | User who made the change to kick off the build | | config.scmContext | String | Yes | Scm context to which user belongs | | config.container | String | No | Container for the build to run in | | config.sha | String | No | SHA used to kick off the build | | config.prRef | String | No | PR branch or reference; required for PR jobs | | config.eventId | Number | No | Id of the event this build belongs to |
Get
Get a build based on id. Can pass the generatedId for the build, or the unique keys for the model, and the id will be determined automatically.
factory.get(id).then(model => {
// do stuff with build model
});
factory.get({ jobId, number }).then(model => {
// do stuff with build model
});
| Parameter | Type | Description | | :------------- | :---- | :------------- | | id | Number | The unique ID for the build | | config.jobId | Number | The unique ID for a job | | config.number | Number | build number |
Get Build Statuses
Get the statuses of the newest builds of jobs based on job ids (in ascending order). Can specify the number of build statuses desired per job id, this defaults to 1. Can specify the number of build statuses to skip per job id, this defaults to 0.
factory.getBuildStatuses(config).then(statuses => {
// do stuff with the statuses
});
| Parameter | Type | Required | Description | | :------------- | :---- | :-------- | :---------- | | config | Object | Yes | Configuration Object | | config.jobIds | Array | Yes | Ids of the jobs
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
