Template engine for (currently) Jira and Email. Uses yaml and jinja2. It helps you create multiple (possibly cross-linked) jira issues and emails from a template.
Project description
Intro
Template engine for (currently) Jira and Email. Uses yaml and jinja2. It helps you create multiple (possibly cross-linked) jira issues and emails from a template.
Table of Contents
Installation
Windows
- Download Workflow_Templater_${version}.exe from the latest release on Releases page.
- Install it.
- Now
workflow-templaterexecutable should be available from Windows Command Prompt (cmd.exe) and from Powershell. - (Optional, recommended) Install Windows Terminal and use it instead of default console.
macOS
- Install python ≥ 3.10.
- Using official Python installer:
- Install python ≥ 3.10 from https://python.org/ ("macOS 64-bit installer")
- Install CA certificates for python, execute in Terminal:
Alternatively, you can double-click on/Applications/Python\ 3.7/Install\ Certificates.commandInstall Certificates.commandin Finder
- Or using Homebrew:
brew install python
- Using official Python installer:
-
pip3 install workflow-templater
Anything else (GNU/Linux, Cygwin, *nix, etc)
Using pip
- Make sure that python ≥ 3.10 is installed
-
pip3 install workflow-templater
Using pipx
-
pipx run workflow-templater
From source
- Clone this repo
- Install dependencies if required
pip3 install -r requirements.txt
- You can execute the script directly:
Or install/build/whatever it withcd workflow_templater ./workflow_templater/__init__.py --helppython3 setup.py
Usage
See
workflow-templater --help
Configuration
To avoid typing same command line arguments each time, it is possible to specify them in configuration file. Configuration file location is OS-specific, to find out correct location for your os, execute workflow-templater --help, you'll see message "--config CONFIG overwrite config file path, default is ${location}" where ${location} is the location of configuration file on your OS. You can create this file and specify values of command-line arguments omitting -- and replacing - with _, for example, --jira-user j_wayne becomes jira_user: j_wayne, --dry-run becomes dry_run: true and so on. You can also use jinja2 in configuration file which evaluates using variables from itself.
Example ~/.config/workflow-templater/config.yaml:
dry_run: true
verbose: true
user: j_wayne
jira: https://jira.example.com/
jira_user: '{{ user }}'
email_user: '{{ user }}'
email_from: '{{ user }}@example.com'
email_smtp: 'smtp.example.com:587'
# avoid typing in the same password for jira and email
jira_keyring_service_name: 'MyCorp LDAP'
email_keyring_service_name: 'MyCorp LDAP'
Template description
Overview
-
Whole workflow template is a directory.
-
There should be one file with variables named
0_common.yaml,00_common.yamlorcommon.yaml. Alternatively, you can name this file as you wish and specify its name with--varsargument. -
There may be any amount of "issue" files:
- ending with ".jira.yaml" for jira issue
- All fields in each jira.issue file are send as is to Jira via API in
fieldsfileld with the exception of following fields:watchers: it's impossible to add watchers during create so it handled separately via this API method.update: its content is sent inupdatevia API- global special fields (see below)
- All fields in each jira.issue file are send as is to Jira via API in
- ending with ".email.yaml" for email.
- ending with ".jira.yaml" for jira issue
-
There may be optional file named
mutate.pywith functionmutatewhich accepts variables, modifies them and returns the result wich can be used in templates.Basic example:
def mutate(variables): variables['new_variable'] = f'{variables["old_var1"]} and {variables["old_var2"]}' return variables
Security note: if you concerned that this feature introduces an ability to execute arbitrary code from the templates, that's correct. However, this is also possible with bare jinja templates (see https://github.com/pallets/jinja/issues/549), so you should make sure that your templates come from trusted sources anyway.
-
Each "issue" file is yaml file where each string value is rendered with Jinja2 using variables from
*common.yamlfile. -
Special variables available for use in jinja:
issuekey_self: Jira issue key or Message-ID of current issue or email.issuekey_<name>: Jira issue key or Message-ID of issue or email named<name>. For example, for issue in filenamesomething.jira.yamlthis variable name would beissuekey_somethingand it can be used in all templates.
-
Global special fields:
foreach: list, create one issue per item in this list. List items should be strings or dicts (in case of dicts you must specifyforeach_namevartoo, see below). In case of strings, issuekey_ variable would be namedissuekey_<name>_<list_value>Example:foreach: - Android - iOS summary: 'Release application for {{ item }}' ...
would finally evaluate to following issues:summary: 'Release application for Android' ...
summary: 'Release application for iOS' ...
foreach_fromvar: if content forforeachvariable is shared between several templates, it's better to specify it in*common.yamlfile and specify here the name of the variable in this file. Example:common.yaml:OSes: - Android - iOS ...
build.jira.yaml:foreach_fromvar: OSes summary: 'Build clients for {{ item }}' ...
release.jira.yaml:foreach_fromvar: OSes summary: 'Release application for {{ item }}' ...
foreach_key: if you don't like default variable name (item) for each item inforeachlist, you may specify it here. Exampleforeach: - Android - iOS foreach_key: os summary: 'Release application for {{ os }}' ...
would finally evaluate to following issues:summary: 'Release application for Android' ...
summary: 'Release application for iOS' ...
foreach_namevar: when foreach is in use, workflow-templater would generate issuekey_ variable name as follows:issuekey_<name>_<list_value>. If you use dicts as foreach values, you need to specify key name in this dicts which will be appended to the end of this variable name. Examplerelease.jira.yamlfile:foreach: - name: Android date: !!timestamp 2019-10-24 06:30:00.0 - name: iOS date: !!timestamp 2019-10-24 10:50:00.0 foreach_namevar: name summary: 'Release application for {{ item.name }}' ...
Now in any other (or the same) issue you can link to this issues as follows:summary: 'Notify community' description: | Android release task: {{ issuekey_release_Android }} iOS release task: {{ issuekey_release_iOS }}
if: if this variable value evaluates to empty string (''),falseorno, this template will be completely ignored. Note: value for this variable is calculated for each item separately whenforeachorforeach_fromvaris in use. Example:foreach: - Android - iOS foreach_key: os if: '{{ os in ["Android", "GNU/Linux"] }}' summary: 'Release application for {{ os }}' ...
would finally evaluate to following issue (only one, obviously):summary: 'Release application for Android' ...
Examples
See basic release example for basic example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file workflow_templater-0.2.17.tar.gz.
File metadata
- Download URL: workflow_templater-0.2.17.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37b2abd0d498fc615550ca2361072e1d981ae88ff27b756b668d0567c622c196
|
|
| MD5 |
f8ff93be8627060fe5d53510354a949f
|
|
| BLAKE2b-256 |
35c35fd1687b75372e5d6ffcdb554eee6366808d49b495bcd14f58b413d66deb
|
Provenance
The following attestation bundles were made for workflow_templater-0.2.17.tar.gz:
Publisher:
github-actions-all-in-one.yml on m-khvoinitsky/workflow-templater
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
workflow_templater-0.2.17.tar.gz -
Subject digest:
37b2abd0d498fc615550ca2361072e1d981ae88ff27b756b668d0567c622c196 - Sigstore transparency entry: 171367566
- Sigstore integration time:
-
Permalink:
m-khvoinitsky/workflow-templater@3102873010f358617270256c9878074dd6fca818 -
Branch / Tag:
refs/tags/0.2.17 - Owner: https://github.com/m-khvoinitsky
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
github-actions-all-in-one.yml@3102873010f358617270256c9878074dd6fca818 -
Trigger Event:
push
-
Statement type:
File details
Details for the file workflow_templater-0.2.17-py3-none-any.whl.
File metadata
- Download URL: workflow_templater-0.2.17-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8341e8a60415818bd94e46a603c2303c88f104e4bd06652e3441a4b6cc68c63d
|
|
| MD5 |
49faa4bcdd494e47f6b5f94eecd4d19e
|
|
| BLAKE2b-256 |
622a6885bf8bfd1c147df052558ac5b9e0fdaf28483cb055d80500adf7f33955
|
Provenance
The following attestation bundles were made for workflow_templater-0.2.17-py3-none-any.whl:
Publisher:
github-actions-all-in-one.yml on m-khvoinitsky/workflow-templater
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
workflow_templater-0.2.17-py3-none-any.whl -
Subject digest:
8341e8a60415818bd94e46a603c2303c88f104e4bd06652e3441a4b6cc68c63d - Sigstore transparency entry: 171367568
- Sigstore integration time:
-
Permalink:
m-khvoinitsky/workflow-templater@3102873010f358617270256c9878074dd6fca818 -
Branch / Tag:
refs/tags/0.2.17 - Owner: https://github.com/m-khvoinitsky
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
github-actions-all-in-one.yml@3102873010f358617270256c9878074dd6fca818 -
Trigger Event:
push
-
Statement type: