1.0.4 • Published 5 years ago
drone-render v1.0.4
drone-render
Render template with CI enviroment injected by Drone CI.
Installation
npm install drone-render --saveHow To Use
const render = require('drone-render');
render(`
{% if build.status %}
{{build.finished | datetime('fromNow')}} build {{build.number}} succeeded. Good job {{build.author}}.
{% else %}
build {{build.number}} failed at {{build.finished | datetime}}. Fix me please.
{% endif %}
`);
//output
//a day ago build 20 succeeded. Good job lord.Template Reference
repo.owner: repository ownerrepo.name: repository namebuild.status: build status type enumeration, either success or failurebuild.event: build event type enumeration, one of push, pull_request, tag, deploymentbuild.number: build numberbuild.commit: git sha for current commitbuild.message: commit message for the current buildbuild.branch: git branch for current commitbuild.tag: git tag for current commitbuild.ref: git ref for current commitbuild.pull_request: pull request number for the current buildbuild.source_branch: source branch for a pull requestbuild.target_branch: target branch for a pull requestbuild.author: git author for current commitbuild.link: link the the build results in dronebuild.started: unix timestamp for build startedbuild.finished: unix timestamp for build finished
Template Filter
uppercasefirst: converts the first letter of a string to uppercasedatetime: converts a unix timestamp to a date time string. Example {{build.started | datetime}}, you can see more info in nunjucks-date-filter- More filter can see builtin-filters
Contributing
Contributions welcome!