Make a pipeline template which captures the stages/jobs/tasks performed.
Make a pipeline for each micro service. The pipeline refers to the template, and lists material.
It might also need to use parameters to pass data to the templates.
We've built a tool called gocdpb, hosted at
https://github.com/magnus-lycka/gocd-pipeline-builderwhich creates pipelines based on a git repo it's in. This tool is still in beta, so there are some rough
edges...
To install this tool:
sudo pip2 install gocdpb
Then you can make a pattern file for it looking something like this:
[
{
"environment": "my_go_environment",
"create-a-pipeline": {
"group": "{{ group }}",
"pipeline": {
"name": "{{ repo_name }}",
"template": "my_pipeline_template",
"parameters": [],
"materials": [
{
"type": "git",
"attributes": {
"url": "{{ repo_url }}",
"branch": "master"
}
}
],
"stages": null
}
}
},
{
"add-downstream-dependencies": [
{
"name": "downstream_pipeline",
"task": {
"type": "fetch",
"attributes": {
"run_if": [
"passed"
],
"pipeline": "{{ repo_name }}",
"stage": "defaultStage",
"job": "defaultJob",
"is_source_a_file": true,
"source": "mybuildartifact.jar"
}
}
}
]
}
]
This json file uses Jinja2 templating (The {{ variable }} stuff). Assuming that you're in a git repo, it will figure out repo_url, and repo_name will default to the basename of the current directory. I.e. you just need to hand it the name of the pipeline group, and how to connect to the go-server. Assuming you make the json available at
http://someserver/gopattern.json, and you log in as 'go' at
http://goserver, you can run:
gocdpb -j
http://someserver/gopattern.json -D group=mygroup -C username=go -P password
Besides the README at
https://github.com/magnus-lycka/gocd-pipeline-builder there are examples of use in
https://github.com/magnus-lycka/gocd-pipeline-builder/tree/master/src/texttest