{"id":22351882,"url":"https://github.com/screwdriver-cd/executor-base","last_synced_at":"2025-07-20T20:05:22.884Z","repository":{"id":45061434,"uuid":"62254780","full_name":"screwdriver-cd/executor-base","owner":"screwdriver-cd","description":"Base class defining the interface for executor implementations","archived":false,"fork":false,"pushed_at":"2025-07-08T22:31:08.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-07-20T20:05:17.184Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cd.screwdriver.cd/pipelines/25/events","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/screwdriver-cd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-06-29T20:12:29.000Z","updated_at":"2025-07-08T22:31:13.000Z","dependencies_parsed_at":"2024-03-12T02:28:59.624Z","dependency_job_id":"284c6162-fd74-4256-81cf-9c7251067388","html_url":"https://github.com/screwdriver-cd/executor-base","commit_stats":{"total_commits":85,"total_committers":25,"mean_commits":3.4,"dds":0.7764705882352941,"last_synced_commit":"9be1c20b94d284879b395c727059bb54e6d58b5e"},"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"purl":"pkg:github/screwdriver-cd/executor-base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screwdriver-cd%2Fexecutor-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screwdriver-cd%2Fexecutor-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screwdriver-cd%2Fexecutor-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screwdriver-cd%2Fexecutor-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/screwdriver-cd","download_url":"https://codeload.github.com/screwdriver-cd/executor-base/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screwdriver-cd%2Fexecutor-base/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266189677,"owners_count":23890065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T12:16:14.851Z","updated_at":"2025-07-20T20:05:22.864Z","avatar_url":"https://github.com/screwdriver-cd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Executor Base\n[![Version][npm-image]][npm-url] ![Downloads][downloads-image] [![Build Status][status-image]][status-url] [![Open Issues][issues-image]][issues-url] ![License][license-image]\n\n\u003e Base class defining the interface for executor implementations\n\nAn executor is an engine that is capable of running a set of docker containers together.\n\ni.e. Jenkins, Kubernetes, ECS, Mesos\n\nThe intention of an executor is to run the `launch` script defined in the [screwdriver job-tools] docker container, which is mounted to a container defined by a screwdriver [task]\n\nThis means:\n\n1. Mounting the job-tools container as a volume to $MOUNT_POINT on another container\n2. Running the `launch` script as the entry point to the task container\n```\nSD_TOKEN=${token} $MOUNT_POINT/launch --api-uri ${api_uri} ${build_id}\n```\n\n## Usage\n\n```bash\nnpm install screwdriver-executor-base\n```\n\n### Interface\n#### Start\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.annotations | Object | Optional key/value object |\n| config.apiUri | String | Screwdriver's API |\n| config.buildId | String | The unique ID for a build |\n| config.container | String | Container for the build to run in |\n| config.token | String | Temporary JWT which Executor must exchange with API to get JWT which can act on behalf of the build |\n\n##### Expected Outcome\nThe start function is expected to create a [task] in the execution engine.\n\n##### Expected Return\nA Promise that resolves if the task is created correctly, or rejects if it fails.\n\n#### Stop\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.buildId | String | The unique ID for a build |\n\n##### Expected Outcome\nThe stop function is expected to stop/cleanup a [task] in the execution engine.\n\n##### Expected Return\nA Promise that resolves if the task is cleaned up correctly, or rejects if it fails.\n\n#### Verify\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.annotations | Object | Optional key/value object |\n| config.apiUri | String | Screwdriver's API |\n| config.buildId | String | The unique ID for a build |\n| config.container | String | Container for the build to run in |\n| config.token | String | Temporary JWT which Executor must exchange with API to get JWT which can act on behalf of the build |\n\n##### Expected Outcome\nThe verify function is expected to check the pods health and status.\n\n##### Expected Return\nA Promise that resolves and returns the message for pod health error or success.\n\n#### Status\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.buildId | String | The unique ID for a build |\n\n##### Expected Outcome\nThe status function is expected to get a human readable status of a [task] in the execution engine.\n\n##### Expected Return\nA Promise that resolves with the current build status, or rejects if it fails.\n\n#### Stats\n##### Expected Outcome\nThe `stats` function is expected to return an object of statistics\n\n#### Status\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.token | String | Temporary JWT for a build |\n| buildTimeout | Number | Build timeout in minutes |\n\n##### Expected Outcome\nThe `exchangeTokenForBuild` function will call API to exchange temporary build JWT with actual build JWT.\n\n##### Expected Return\nA Promise which resolves to actual build JWT\n\n\n#### CleanUp\n##### Expected Outcome\nThe cleanUp function is expected to handle any housekeeping operations like closing connections, queues during the SIGTERM event.\nDefault is no-op\n\n##### Expected Return\nA Promise that resolves or rejects.\n\n#### StartTimer\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.annotations | Object | Optional key/value object |\n| config.buildStatus | String | The status of the  build |\n| config.buildId | String | The unique ID for a build |\n| config.startTime | String | ISO start time of the build |\n| config.jobId | String | job id of the build |\n##### Expected Outcome\nThe StartTimer function is expected to add buildId as key and timeout config value to timeout queue\nDefault is no-op\n\n##### Expected Return\nA Promise that resolves or rejects.\n\n#### StopTimer\n##### Required Parameters\n| Parameter        | Type  |  Description |\n| :-------------   | :---- | :-------------|\n| config        | Object | Configuration Object |\n| config.buildId | String | The unique ID for a build |\n##### Expected Outcome\nThe StopTimer function is expected to remove key/value buildId from timeout queue\nDefault is no-op\n\n##### Expected Return\nA Promise that resolves or rejects.\n\n\n## Extending\nTo make use of the validation function for start and stop, you need to\noverride the `_start` , `_stop` and `_cleanUp` methods.\n\n```js\nclass MyExecutor extends Executor {\n    // Implement the interface\n    _start(config) {\n        if (config.buildId) {\n            return this.exchangeTokenForBuild(config.token, buildTimeout).then(buildToken =\u003e {\n                // do stuff here...\n                return Promise.resolve(null);\n            });\n        }\n\n        return Promise.reject(new Error('Error starting executor'));\n    }\n}\n\nconst executor = new MyExecutor({});\nexecutor.start({\n    buildId: '4b8d9b530d2e5e297b4f470d5b0a6e1310d29c5e',\n    container: 'node:4',\n    apiUri: 'http://localhost:8080',\n    token: 'abcdefg'\n}, (err) =\u003e {\n    // do something...\n});\n```\n\n## Testing\n\n```bash\nnpm test\n```\n\n## License\n\nCode licensed under the BSD 3-Clause license. See LICENSE file for terms.\n\n[npm-image]: https://img.shields.io/npm/v/screwdriver-executor-base.svg\n[npm-url]: https://npmjs.org/package/screwdriver-executor-base\n[downloads-image]: https://img.shields.io/npm/dt/screwdriver-executor-base.svg\n[license-image]: https://img.shields.io/npm/l/screwdriver-executor-base.svg\n[issues-image]: https://img.shields.io/github/issues/screwdriver-cd/screwdriver.svg\n[issues-url]: https://github.com/screwdriver-cd/screwdriver/issues\n[status-image]: https://cd.screwdriver.cd/pipelines/25/badge\n[status-url]: https://cd.screwdriver.cd/pipelines/25\n[task]: https://github.com/screwdriver-cd/data-schema/blob/master/model/task.js\n[screwdriver job-tools]: https://github.com/screwdriver-cd/job-tools\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrewdriver-cd%2Fexecutor-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrewdriver-cd%2Fexecutor-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrewdriver-cd%2Fexecutor-base/lists"}