forked from Osthanes/container_deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default_pipelne.yml
115 lines (115 loc) · 7.42 KB
/
default_pipelne.yml
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
---
stages:
- name: Build
inputs:
- type: git
branch: master
triggers:
- type: commit
jobs:
- name: Docker build
type: builder
extension_id: ibm.devops.services.pipeline.container.builder
target:
url: ${CF_TARGET_URL}
organization: ${CF_ORGANIZATION}
space: ${CF_SPACE}
IMAGE_NAME: ${CF_APP}
USE_CACHED_LAYERS: 'true'
COMMAND: "#!/bin/bash\n# The following colors have been defined to help with presentation\
\ of logs: green, red, label_color, no_color. \necho -e \"${label_color}Starting\
\ build script${no_color}\"\n\n# The IBM Container Service CLI (ice), Git client\
\ (git), IDS Inventory CLI (ids-inv) and Python 2.7.3 (python) have been installed.\n\
# Based on the organization and space selected in the Job credentials are in\
\ place for both IBM Container Service and IBM Bluemix \n#####################\n\
# Run unit tests #\n#####################\necho -e \"${label_color}No unit\
\ tests cases have been checked in ${no_color}\"\n\n######################################\n\
# Build Container via Dockerfile #\n######################################\n\
\n# REGISTRY_URL=${CCS_REGISTRY_HOST}/${NAMESPACE}\n# FULL_REPOSITORY_NAME=${REGISTRY_URL}/${IMAGE_NAME}:${APPLICATION_VERSION}\n\
\nif [ -f Dockerfile ]; then \n echo -e \"${label_color}Building ${FULL_REPOSITORY_NAME}\
\ ${no_color}\"\n BUILD_COMMAND=\"\"\n if [ \"${USE_CACHED_LAYERS}\" ==\
\ \"true\" ]; then \n BUILD_COMMAND=\"ice build --pull --tag ${FULL_REPOSITORY_NAME}\
\ ${WORKSPACE}\"\n ${BUILD_COMMAND}\n RESULT=$?\n else \n \
\ BUILD_COMMAND=\"ice build --no-cache --tag ${FULL_REPOSITORY_NAME} ${WORKSPACE}\"\
\n ${BUILD_COMMAND}\n RESULT=$?\n fi \n\n if [ $RESULT -ne\
\ 0 ]; then\n echo -e \"${red}Error building image ${no_color}\" | tee\
\ -a \"$ERROR_LOG_FILE\"\n echo \"Build command: ${BUILD_COMMAND}\"\n\
\ ice info \n ice images\n ${EXT_DIR}/print_help.sh\n \
\ exit 1\n else\n echo -e \"${green}Container build of ${FULL_REPOSITORY_NAME}\
\ was successful ${no_color}\"\n fi \nelse \n echo -e \"${red}Dockerfile\
\ not found in project${no_color}\"\n exit 1\nfi \n\n######################################################################################\n\
# Copy any artifacts that will be needed for deployment and testing to $WORKSPACE\
\ #\n######################################################################################\n\
echo \"IMAGE_NAME=${FULL_REPOSITORY_NAME}\" >> $ARCHIVE_DIR/build.properties"
- name: Deploy
inputs:
- type: job
stage: Build
job: Docker build
triggers:
- type: stage
properties:
- name: ROUTE_HOSTNAME
value: ${CF_APP}
type: text
jobs:
- name: Group deploy
type: deployer
extension_id: ibm.devops.services.pipeline.docker.deploy.ice
target:
url: ${CF_TARGET_URL}
organization: ${CF_ORGANIZATION}
space: ${CF_SPACE}
PORT: '80'
DEPLOY_TYPE: red_black
CONTAINER_NAME: ${CF_APP}
COMMAND: "#!/bin/bash\n# The following are some example deployment scripts. Use\
\ these as is or fork them and include your updates here:\necho -e \"${label_color}Starting\
\ deployment script${no_color}\"\n\n\n# To view/fork this script goto: https://github.com/Osthanes/deployscripts\n\
# git_retry will retry git calls to prevent pipeline failure on temporary github\
\ problems\n# the code can be found in git_util.sh at https://github.com/Osthanes/container_deployer\n\
git_retry clone https://github.com/Osthanes/deployscripts.git deployscripts\n\
\n\n# You can deploy your Image as either a single Container or as a Container\
\ \n# Group. A Container Group deploys a number of containers to enhance\n\
# scalability or reliability. By default we will deploy as a single \n# container.\
\ To switch to a group deploy, comment out the line below\n# containing deploycontainer.sh\
\ and uncomment the line for deploygroup.sh\n\n# Deploy with containers:\n#\
\ Optional environment properties (can be set directly in this script, or defined\
\ as environment properties):\n# NAME Value Description\n\
# ============= ========= ==============\n# 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.\n\
# CONTAINER_SIZE String Specify container size: m1.tiny (256),\
\ m1.small (512), m1.medium (1024), m1.large (2048).\n# \
\ Default is m1.tiny (256).\n# CONCURRENT_VERSIONS Number \
\ Number of versions of this container to leave active. \n# \
\ Default is 1\n#\n#/bin/bash deployscripts/deploycontainer.sh\n\
\n# Deploy Container Group:\n# Optional environment properties (can be set directly\
\ in this script, or defined as environment properties):\n# NAME \
\ Value Description\n# ============= ========= ==============\n\
# 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.\n# 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.\n# 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.\n# DESIRED_INSTANCES: Number Specify\
\ the number of instances in the group. Default value is 1.\n# AUTO_RECOVERY:\
\ Boolean Set auto-recovery to true/false. Default value is false.\n\
\n# Default is false.\n# CONTAINER_SIZE\
\ String Specify container size: m1.tiny (256), m1.small (512), m1.medium\
\ (1024), m1.large (2048).\n# Default is\
\ m1.tiny (256).\n# CONCURRENT_VERSIONS Number Number of versions of\
\ this group to leave active.\n# Default\
\ is 1\n# IF YOU WANT CONTAINER GROUPS .. uncomment the next line, and comment\
\ out the previous deployment line (/bin/bash deployscripts/deploygroup.sh)\n\
/bin/bash deployscripts/deploygroup.sh\n\nRESULT=$?\n\n#########################\n\
# Environment DETAILS #\n#########################\n# The environment has\
\ been setup.\n# 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.\n# Based on the organization and space selected in the Job\
\ credentials are in place for both IBM Container Service and IBM Bluemix\n\n\
# The following colors have been defined to help with presentation of logs:\
\ green, red, label_color, no_color.\nif [ $RESULT -ne 0 ]; then\n echo -e\
\ \"${red}Executed failed or had warnings ${no_color}\"\n ${EXT_DIR}/print_help.sh\n\
\ exit $RESULT\nfi\necho -e \"${green}Execution complete${no_label}\""