Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.editorconfig
.eslintignore
.eslintrc.yaml
.gitignore
.npmignore
CONTRIBUTING.md
LICENSE
README.md
getVersionFromTag.js
index.js
package.json
publish.js
remove.js
removeTag.js
screwdriver.yaml
tag.js
validate.js

README.md

template-main

Version Downloads Build Status Open Issues Dependency Status License

Validates and publishes templates

Usage

npm install screwdriver-template-main

Create a Screwdriver pipeline with your template repo and start the build to validate and publish it.

To update a Screwdriver template, make changes in your SCM repository and rerun the pipeline build.

Validating a template

Run the template-validate script. By default, the path ./sd-template.yaml will be read. However, a user can specify a custom path using the env variable: SD_TEMPLATE_PATH.

Example screwdriver.yaml:

shared:
    image: node:6
jobs:
    main:
        requires: [~pr, ~commit]
        steps:
            - install: npm install screwdriver-template-main
            - validate: ./node_modules/.bin/template-validate
        environment:
            SD_TEMPLATE_PATH: ./path/to/template.yaml

template-validate can print a result as json by passing --json option to the command.

$ ./node_modules/.bin/template-validate --json
{"valid":true}

Publishing a template

Run the template-publish script. By default, the path ./sd-template.yaml will be read. However, a user can specify a custom path using the env variable: SD_TEMPLATE_PATH.

Example screwdriver.yaml with validation and publishing:

shared:
    image: node:6
jobs:
    main:
        requires: [~pr, ~commit]
        steps:
            - install: npm install screwdriver-template-main
            - validate: ./node_modules/.bin/template-validate
    publish:
        requires: main
        steps:
            - install: npm install screwdriver-template-main
            - publish: ./node_modules/.bin/template-publish --tag stable

template-publish can print a result as json by passing --json option to the command. template-publish will tag the published version as well. The default tag is latest if none is specified.

$ ./node_modules/.bin/template-publish --json
{name:"template/foo",version:"1.2.3",tag:"stable"}

Removing a template

To remove a template, run the template-remove script. You'll need to add an argument for the template name. Removing a template will remove all of its versions.

Example screwdriver.yaml with validation and publishing, and template removal as a detached job:

shared:
    image: node:6
jobs:
    main:
        requires: [~pr, ~commit]
        steps:
            - install: npm install screwdriver-template-main
            - validate: ./node_modules/.bin/template-validate
    publish:
        requires: main
        steps:
            - install: npm install screwdriver-template-main
            - publish: ./node_modules/.bin/template-publish
    remove_template:
        steps:
            - install: npm install screwdriver-template-main
            - remove: ./node_modules/.bin/template-remove --name templateName

template-remove can print a result as json by passing --json option to the command.

$ ./node_modules/.bin/template-remove --json --name templateName
{"name":"templateName"}

Tagging a template

Optionally, tag a template using the template-tag script. This must be done in the same pipeline that published the template. You'll need to add arguments for the template name and tag. You can optionally specify a version; the version must be an exact version, not just a major or major.minor one. If omitted, the latest version will be tagged.

Example screwdriver.yaml with validation and publishing and tagging:

shared:
    image: node:6
jobs:
    main:
        requires: [~pr, ~commit]
        steps:
            - install: npm install screwdriver-template-main
            - validate: ./node_modules/.bin/template-validate
    publish:
        requires: main
        steps:
            - install: npm install screwdriver-template-main
            - publish: ./node_modules/.bin/template-publish
            - tag: ./node_modules/.bin/template-tag --name templateName --version 1.2.3 --tag stable

template-tag can print a result as json by passing --json option to the command.

$ ./node_modules/.bin/template-tag --json --name templateName --version 1.2.3 --tag stable
{"name":"templateName","tag":"stable","version":"1.2.3"}

Removing a template tag

To remove a template tag, run the template-remove-tag binary. This must be done in the same pipeline that published the template. You'll need to specify the template name and tag as arguments.

Example screwdriver.yaml with validation, publishing and tagging, and tag removal as a detached job:

shared:
    image: node:6
    steps:
        - init: npm install screwdriver-template-main
jobs:
    main:
        requires: [~pr, ~commit]
        steps:
            - validate: ./node_modules/.bin/template-validate
    publish:
        requires: main
        steps:
            - publish: ./node_modules/.bin/template-publish
            - tag: ./node_modules/.bin/template-tag --name templateName --version 1.0.0 --tag latest
    detached_remove_tag:
        steps:
            - remove: ./node_modules/.bin/template-remove-tag --name templateName --tag latest

template-remove-tag can print a result as json by passing --json option to the command.

$ ./node_modules/.bin/template-remove-tag --json --name templateName --tag stable
{"name":"templateName","tag":"stable"}

Getting the version from a template tag

To get the version from a template tag, run the template-get-version-from-tag binary. This must be done in the same pipeline that published the template. You'll need to add arguments for the template name and tag.

Example screwdriver.yaml with validation, publishing and tagging, and getting a version as a detached job:

shared:
    image: node:6
    steps:
        - init: npm install screwdriver-template-main
jobs:
    main:
        requires: [~pr, ~commit]
        steps:
            - validate: ./node_modules/.bin/template-validate
    publish:
        requires: main
        steps:
            - publish: ./node_modules/.bin/template-publish
            - tag: ./node_modules/.bin/template-tag --name templateName --version 1.0.0 --tag latest
    detached_get_version_from_tag:
        steps:
            - get_version: ./node_modules/.bin/template-get-version-from-tag --name templateName --tag latest

Testing

npm test

License

Code licensed under the BSD 3-Clause license. See LICENSE file for terms.