forked from rjminsha/pipeline_service_docker_deployer_ice
-
Notifications
You must be signed in to change notification settings - Fork 6
/
extension.json
177 lines (165 loc) · 7.11 KB
/
extension.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
{
"id": "ibm.devops.services.pipeline.docker.deploy.ice",
"version": 2,
"name_key": "ExtName",
"desc_key": "ExtDesc",
"extension_type": "Deploy",
"message_key": "ExtMessage",
"inputs": [
{
"type": "Artifacts",
"inclusion" : "always"
},
{
"type": "Bluemix",
"inclusion" : "always",
"regions": ["ibm:ys1:us-south", "ibm:yp:us-south", "ibm:yp:eu-gb"]
}
],
"params": [
{
"name": "DEPLOY_TYPE",
"type": "Text",
"required": "false",
"default_value": "red_black",
"label_key": "DEPLOY_TYPE_KEY",
"desc_key": "DEPLOY_TYPE_DESC"
},
{
"name": "CONTAINER_NAME",
"type": "Text",
"required": "true",
"default_value": "myApplicationName",
"label_key": "CONTAINER_NAME_KEY",
"desc_key": "CONTAINER_NAME_DESC"
},
{
"name": "PORT",
"type": "Text",
"required": "false",
"default_value": "80",
"label_key": "PORT_KEY",
"desc_key": "PORT_DESC"
},
{
"name": "OPTIONAL_ARGS",
"type": "Text",
"required": "false",
"default_value": "",
"label_key": "ARGS_KEY",
"desc_key": "ARGS_DESC"
},
{
"name": "COMMAND",
"type": "TextArea",
"required": "true",
"default_value" : "#!/bin/bash
# The following are some example deployment scripts. Use these as is or fork them and include your updates here:
echo -e \"${label_color}Starting deployment script${no_color}\"
# To view/fork this script goto: https://github.com/Osthanes/deployscripts
# git_retry will retry git calls to prevent pipeline failure on temporary github problems
# the code can be found in git_util.sh at https://github.com/Osthanes/container_deployer
git_retry clone https://github.com/Osthanes/deployscripts.git deployscripts
# You can deploy your Image as either a single Container or as a Container
# Group. A Container Group deploys a number of containers to enhance
# scalability or reliability. By default we will deploy as a single
# container. To switch to a group deploy, comment out the line below
# containing deploycontainer.sh and uncomment the line for deploygroup.sh
# Deploy with containers:
# Optional environment properties (can be set directly in this script, or defined as environment properties):
# NAME Value Description
# ============= ========= ==============
# BIND_TO String Specify a Bluemix application name that whose bound services you wish to make available to the container. By default this is not set.
# CONTAINER_SIZE String Specify container size: pico (64), nano (128), micro (256), tiny (512), small (1024), medium (2048),
# large (4096), x-large (8192), 2x-large (16384).
# Default is micro (256).
# CONCURRENT_VERSIONS Number Number of versions of this container to leave active.
# Default is 1
#
/bin/bash deployscripts/deploycontainer.sh
# Deploy Container Group:
# Optional environment properties (can be set directly in this script, or defined as environment properties):
# NAME Value Description
# ============= ========= ==============
# ROUTE_HOSTNAME String Specify the Hostname for the Cloud Foundry Route you wish to assign to this container group. By default this is not set.
# ROUTE_DOMAIN String Specify domain name for the Cloud Foundry Route you wish to assign to this container group. By default this is not set.
# BIND_TO String Specify a Bluemix application name that whose bound services you wish to make available to the container. By default this is not set.
# DESIRED_INSTANCES: Number Specify the number of instances in the group. Default value is 1.
# AUTO_RECOVERY: Boolean Set auto-recovery to true/false. Default value is false.
# Default is false.
# CONTAINER_SIZE String Specify container size: pico (64), nano (128), micro (256), tiny (512), small (1024), medium (2048),
# large (4096), x-large (8192), 2x-large (16384).
# Default is micro (256).
# CONCURRENT_VERSIONS Number Number of versions of this group to leave active.
# Default is 1
# IF YOU WANT CONTAINER GROUPS .. uncomment the next line, and comment out the previous deployment line (/bin/bash deployscripts/deploygroup.sh)
#/bin/bash deployscripts/deploygroup.sh
RESULT=$?
# source the deploy property file
if [ -f \"${DEPLOY_PROPERTY_FILE}\" ]; then
source \"$DEPLOY_PROPERTY_FILE\"
fi
#########################
# Environment DETAILS #
#########################
# The environment has been setup.
# The Cloud Foundry CLI (cf), IBM Container Service CLI (ice), Git client (git), IDS Inventory CLI (ids-inv) and Python 2.7.3 (python) have been installed.
# Based on the organization and space selected in the Job credentials are in place for both IBM Container Service and IBM Bluemix
# The following colors have been defined to help with presentation of logs: green, red, label_color, no_color.
if [ $RESULT -ne 0 ]; then
echo -e \"${red}Executed failed or had warnings ${no_color}\"
${EXT_DIR}/print_help.sh
exit $RESULT
fi
echo -e \"${green}Execution complete${no_label}\"",
"label_key": "COMMAND_KEY",
"desc_key": "COMMAND_DESC"
}
],
"outputs": [
],
"execution": {
"type": "JenkinsDocker",
"shell": "#!/bin/bash
set +x
set +e
export INIT_START_TIME=$(date +\"%s\")
export DEPLOY_TYPE=#DEPLOY_TYPE#
export CONTAINER_NAME=#CONTAINER_NAME#
export PORT=\"#PORT#\"
export OPTIONAL_ARGS=\"#OPTIONAL_ARGS#\"
# OSSC line
dpkg -l | grep '^ii' > $EXT_DIR/pkglist
. $EXT_DIR/_init.sh
# OSSC line
dpkg -l | grep '^ii' > $EXT_DIR/pkglist2
if [[ $DEBUG -eq 1 ]]; then
diff $EXT_DIR/pkglist $EXT_DIR/pkglist2
fi
INIT_END_TIME=$(date +\"%s\")
INIT_EST_TIME=$(($INIT_END_TIME-$INIT_START_TIME))
echo -e \"Init runtime of `date -u -d @\"$INIT_EST_TIME\" +\'%-Mm %-Ss\'`\"
# place command into a temp script file
cat > script.sh << '__EOF__'
#!/bin/bash
function save_env_vars_on_exit() {
echo \"#!/bin/bash\" > \"$EXT_DIR/save_vars.sh\"
export -p >> \"$EXT_DIR/save_vars.sh\"
}
trap \"save_env_vars_on_exit\" EXIT
#COMMAND#
__EOF__
# call the script in a subscript
/bin/bash -e script.sh
PIPE_SCR_RESULT=$?
# restore the saved exported vars
source $EXT_DIR/save_vars.sh
if [ $PIPE_SCR_RESULT -ne 0 ]; then
exit $PIPE_SCR_RESULT
fi"
}
},
"project": "https://hub.jazz.net/project/rjminsha/pipeline_service_docker_deployer_ice",
"project_example": "https://hub.jazz.net/pipeline/rjminsha/ice-pipeline_demo",
"project_contact": "[email protected]"
}