Skip to content

Instantly share code, notes, and snippets.

@shajra
Created June 8, 2016 01:02
Show Gist options
  • Save shajra/e2cdc4060670428b8ff9782220c6391d to your computer and use it in GitHub Desktop.
Save shajra/e2cdc4060670428b8ff9782220c6391d to your computer and use it in GitHub Desktop.
def pipeline_update:
{
"name": .name,
"template": "c12e-ci",
"label_template": (.name + "-${COUNT}"),
"enable_pipeline_locking": false,
"materials": [
{
"type": "git",
"attributes": {
"name": .name,
"url": ("[email protected]:" + .git_org + "/" + .name + ".git"),
"branch": .git_branch,
"auto_update": true,
"shallow_clone": true
}
}
]
};
def pipeline_create:
{
"group": .group,
"pipeline": pipeline_update
};
def defaults:
{
"git_org": "CognitiveScale",
"git_branch": "master",
} + .;
def validate(required_key):
if has(required_key)
then .
else error("missing key: " + required_key)
end;
def validate_update:
validate("name")
| validate("git_org")
| validate("git_branch");
def validate_create:
validate_update | validate("group");
defaults |
if $create
then validate_create | pipeline_create
else validate_update | pipeline_update
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment