taskrun
Simple cli that helps to create jobs from configurable commands for different stages.
Installation
go install github.com/Drafteame/taskrun@latest
Usage
taskrun -h
Job file definition
jobs:
stage1:
- name: some-job
command: echo
args:
- '"Hello, World!"'
env:
# This remote loads the values from the specified source and key. If the source is not specified
# it will be omitted
remote:
source: secretsmanager
key: secret-name
# This vars will be loaded after the remote, so if there is a conflict the remote value will be overwritten.
vars:
# This is a hardcoded value
SOME_VAR:
value: "some-value"
# This is a value from SSM
SOME_SSM_VAR:
source: ssm
key: /path/to/ssm/parameter
# This is a value from environment variable
SOME_ENV_VAR:
source: env
key: SOME_ENV_VAR_NAME
Stages
Stages are a way to configure different behavior for different environments. For example, you can have a stage for
development, another for testing, and another for production.
You should define at least one stage in the job file, so it can be executed as the default stage.
If you have more than one stage defined, you can execute a specific stage using the -s flag.
taskrun print job-name -s stage1
When you have defined more than one stage, if you don't specify the stage, the default stage will be taken as the first
stage defined:
jobs:
stage1:
- name: some-job
command: echo
args:
- '"Hello, World! default"'
stage2:
- name: some-job
command: echo
args:
- '"Hello, World!"'
taskrun print same-job
# This will execute the stage1
If you want to define a different stage as the default stage, you can use the default_stage configuration.
default_stage: stage2
jobs:
stage1:
- name: some-job
command: echo
args:
- '"Hello, World! default"'
stage2:
- name: some-job
command: echo
args:
- '"Hello, World!"'
taskrun print same-job
# This will execute the stage2
Templating
Jobs file supports variable replacing using notation similar to serverless framework.
jobs:
stage1:
- name: some-job
command: echo
args:
- '"${env:MY_ENV_VAR} ${sys:cwd}"'
env:
vars:
MY_ENV_VAR:
value: "Hello from"
Supported replacing vars
| Notation |
Description |
${env:<some-env>} |
Replace the value of the environment variable after source resolution |
${sys:cwd} |
It sets the value of the current working directory as absolute path |