forked from Osthanes/docker_builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.json
132 lines (125 loc) · 4.59 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
{
"id": "ibm.devops.services.pipeline.container.builder",
"version": 2,
"name_key": "ExtName",
"desc_key": "ExtDesc",
"extension_type": "Build",
"message_key": "ExtMessage",
"inputs": [
{
"type": "Bluemix",
"inclusion" : "always",
"regions": ["ibm:ys1:us-south", "ibm:yp:us-south", "ibm:yp:eu-gb"]
}
],
"params": [
{
"name": "USE_CACHED_LAYERS",
"type": "Checkbox",
"required": "false",
"default_value":"true",
"label_key": "CACHE_KEY",
"desc_key": "CACHE_DESC"
},
{
"name": "IMAGE_NAME",
"type": "Text",
"required": "false",
"label_key": "IMAGE_NAME_KEY",
"desc_key": "IMAGE_NAME_DESC"
},
{
"name": "COMMAND",
"type": "TextArea",
"required": "true",
"default_value" : "#!/bin/bash
# The following colors have been defined to help with presentation of logs: green, red, label_color, no_color.
log_and_echo \"$LABEL\" \"Starting build script\"
# The IBM Container BM Containers plug-in (cf ic), Git client (git), and IDS Inventory CLI (ids-inv) 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
#####################
# Run unit tests #
#####################
log_and_echo \"$LABEL\" \"No unit tests cases have been checked in\"
######################################
# Build Container via Dockerfile #
######################################
# REGISTRY_URL=${CCS_REGISTRY_HOST}/${NAMESPACE}
# FULL_REPOSITORY_NAME=${REGISTRY_URL}/${IMAGE_NAME}:${APPLICATION_VERSION}
# If you wish to receive slack notifications, set SLACK_WEBHOOK_PATH as a property on the stage.
if [ -f Dockerfile ]; then
log_and_echo \"$LABEL\" \"Building ${FULL_REPOSITORY_NAME}\"
${EXT_DIR}/utilities/sendMessage.sh -l info -m \"New container build requested for ${FULL_REPOSITORY_NAME}\"
# build image
BUILD_COMMAND=\"\"
if [ \"${USE_CACHED_LAYERS}\" == \"true\" ]; then
BUILD_COMMAND=\"build --pull --tag ${FULL_REPOSITORY_NAME} ${WORKSPACE}\"
ice_retry ${BUILD_COMMAND}
RESULT=$?
else
BUILD_COMMAND=\"build --no-cache --tag ${FULL_REPOSITORY_NAME} ${WORKSPACE}\"
ice_retry ${BUILD_COMMAND}
RESULT=$?
fi
if [ $RESULT -ne 0 ]; then
log_and_echo \"$ERROR\" \"Error building image\"
ice_retry info
ice_retry images
${EXT_DIR}/print_help.sh
${EXT_DIR}/utilities/sendMessage.sh -l bad -m \"Container build of ${FULL_REPOSITORY_NAME} failed. $(get_error_info)\"
exit 1
else
log_and_echo \"$SUCCESSFUL\" \"Container build of ${FULL_REPOSITORY_NAME} was successful\"
${EXT_DIR}/utilities/sendMessage.sh -l good -m \"Container build of ${FULL_REPOSITORY_NAME} was successful\"
fi
else
log_and_echo \"$ERROR\" \"Dockerfile not found in project\"
${EXT_DIR}/utilities/sendMessage.sh -l bad -m \"Failed to get Dockerfile. $(get_error_info)\"
exit 1
fi
######################################################################################
# Copy any artifacts that will be needed for deployment and testing to $WORKSPACE #
######################################################################################
echo \"IMAGE_NAME=${FULL_REPOSITORY_NAME}\" >> $ARCHIVE_DIR/build.properties",
"label_key": "COMMAND_KEY",
"desc_key": "COMMAND_DESC"
}
],
"outputs": [
{
"type": "Artifacts",
"inclusion" : "always"
}
],
"execution": {
"type": "JenkinsDocker",
"shell": "#!/bin/bash
set +x
set +e
export INIT_START_TIME=$(date +\"%s\")
export IMAGE_NAME=#IMAGE_NAME#
export USE_CACHED_LAYERS=#USE_CACHED_LAYERS#
# 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__'
#COMMAND#
__EOF__
# set to fail if script.sh fails
set -e
/bin/bash script.sh"
}
},
"project": "https://hub.jazz.net/project/alchemy/Alchemy-Ostanes",
"project_example": "https://hub.jazz.net/pipeline/rjminsha/ice-pipeline_demo",
"project_contact": "rjminsha@us.ibm.com"
}