File tree Expand file tree Collapse file tree 4 files changed +71
-7
lines changed
incubating/pipeline-trigger-merge Expand file tree Collapse file tree 4 files changed +71
-7
lines changed Original file line number Diff line number Diff line change @@ -49,4 +49,23 @@ MergeTriggersIntoPipelines:
49
49
SPEC : spec.yml
50
50
ONLY_CHANGED : true
51
51
TRIGGERS_SUBDIR : " triggers"
52
- ` ` `
52
+ ` ` `
53
+
54
+ ## Testing and Debugging
55
+
56
+ In order to speed up development (or debugging), we recommend to run the image
57
+ locally and mounting the your local folder to your container.
58
+
59
+ To do that,
60
+
61
+ 1. we will be running docker run (be sure the daemon is running on your local box)
62
+ 2. mount local folder there your spec and triggers are located
63
+ 3. mount the .cfconfig file (to be able to call the CLI)
64
+ 4. Pass variables as environment variables
65
+
66
+ ` ` ` sh
67
+ docker run -v ~/.cfconfig:/root/.cfconfig -v $(pwd)/sample:/foo \
68
+ -e SPEC=/foo/spec.yml \
69
+ -e TRIGGERS='/foo/TRIGGERS /foo/trig1.yml' \
70
+ quay.io/codefreshplugins/pipeline-trigger-merge:1.1.0
71
+ ```
Original file line number Diff line number Diff line change 1
- # /bin/#!/usr/ bin/env bash
1
+ #! / bin/bash
2
2
3
3
process_dir () {
4
4
echo " Processing trigger directory $1 "
@@ -25,11 +25,40 @@ process_file() {
25
25
fi
26
26
echo " WARNING: Unknown trigger file $1 "
27
27
}
28
- export curdir=` pwd`
29
- export count=1
28
+
29
+ # exit on error
30
+ set -e
31
+ echo " pipeline-trigger-merge v1.1.0"
32
+
33
+ count=1
30
34
echo " Merging pipeline spec $SPEC with triggers $TRIGGERS "
31
35
for f in ` echo $TRIGGERS ` ; do
36
+ # is path absolute
37
+ if [[ " $f " = /* ]] ; then
38
+ curdir=" /"
39
+ else
40
+ curdir=` pwd`
41
+ fi
32
42
process_file $f
33
43
done
44
+
34
45
echo " Creating/Updating final pipeline"
35
- codefresh create pipeline -f $SPEC || codefresh replace -f $SPEC
46
+
47
+ # Get pipeline name
48
+ echo " Checking if pipeline already exists"
49
+ name=$( yq ' .metadata.name' $SPEC )
50
+ codefresh get pip $name > pipeline.log 2>&1 || true
51
+
52
+ # Check if pipeline exists
53
+ if [ ` grep -c PIPELINE_NOT_FOUND pipeline.log` -eq 0 ] ; then
54
+ echo " Updating final pipeline"
55
+ cmd=" codefresh replace -f $SPEC "
56
+ else
57
+ echo " Creating final pipeline"
58
+ cmd=" codefresh create pipeline -f $SPEC "
59
+ fi
60
+
61
+ # Check for error when creating/updating the pipeline
62
+ echo " Checking for errors"
63
+ $cmd 2>&1 | tee pipeline.log
64
+ exit ` grep -c ' Yaml validation errors' pipeline.log`
Original file line number Diff line number Diff line change 27
27
build :
28
28
title : " Building Docker image"
29
29
type : " build"
30
+ registry : docker
30
31
image_name : " codefresh-io/cli"
31
32
working_directory : " ${{clone}}"
32
33
tag : " latest"
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ kind: step-type
2
2
version : ' 1.0'
3
3
metadata :
4
4
name : pipeline-trigger-merge
5
- version : 1.0.2
5
+ version : 1.1.0
6
6
isPublic : true
7
7
description : >-
8
8
Merge a pipeline spec and a list of triggers (files or directories) to
@@ -65,14 +65,29 @@ spec:
65
65
"TRIGGERS_SUBDIR": {
66
66
"type": "string",
67
67
"description": "The subdirectory that holds a pipeline's triggers if looping. Defaults to 'triggers'."
68
+ },
69
+ "REGISTRY": {
70
+ "type": "string",
71
+ "description": "Docker Registry for step's image.",
72
+ "default": "quay.io"
73
+ },
74
+ "IMAGE": {
75
+ "type": "string",
76
+ "description": "Image name for step's image.",
77
+ "default": "codefreshplugins/pipeline-trigger-merge"
78
+ },
79
+ "IMAGE_TAG": {
80
+ "type": "string",
81
+ "description": "Image tag for step's image.",
82
+ "default": "1.1.0"
68
83
}
69
84
}
70
85
}
71
86
72
87
stepsTemplate : |-
73
88
pipeline-trigger-merge:
74
89
name: pipeline-trigger-merge
75
- image: quay.io/codefreshplugins/pipeline-trigger-merge:1.0.2
90
+ image: '[[.Arguments.REGISTRY]]/[[.Arguments.IMAGE]]:[[.Arguments.IMAGE_TAG]]'
76
91
environment:
77
92
[[ range $key, $val := .Arguments ]]
78
93
- '[[ $key ]]=[[ $val ]]'
You can’t perform that action at this time.
0 commit comments