-
Notifications
You must be signed in to change notification settings - Fork 22
/
wercker.yml
133 lines (127 loc) · 5.15 KB
/
wercker.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
box: combient/java-mvn
build:
steps:
# Build Inventory REST application
- script:
name: Customize application home page
code: sed "s|@@NAMESPACE@@|${WERCKER_APPLICATION_OWNER_NAME}|g" -i $WERCKER_ROOT/src/main/webapp/WEB-INF/views/CreditScore.jsp
- script:
name: Print jsp source
code: cat $WERCKER_ROOT/src/main/webapp/WEB-INF/views/CreditScore.jsp
- script:
name: Customize application context path
code: sed "s|replaceme|${WERCKER_APPLICATION_OWNER_NAME}|g" -i $WERCKER_ROOT/src/main/webapp/WEB-INF/weblogic.xml
- script:
name: Print weblogic.xml source
code: cat $WERCKER_ROOT/src/main/webapp/WEB-INF/weblogic.xml
- script:
name: Maven build for WebLogic
code: mvn clean package -Pweblogic
push-dockerhub:
steps:
# Push to public docker repo
- internal/docker-push:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
tag: latest
repository: $DOCKERHUB_REPOSITORY
registry: https://index.docker.io/v2/
cmd: java -jar /pipeline/source/target/loan-0.1.0.war
push:
steps:
# Push to public docker repo Container Registry (CR)
- internal/docker-push:
tag: $WERCKER_GIT_BRANCH-$WERCKER_GIT_COMMIT
repository: wcr.io/$WERCKER_APPLICATION_OWNER_NAME/creditscoreapp
cmd: java -jar /pipeline/source/target/loan-0.1.0.war
inject-secret:
box:
id: alpine
cmd: /bin/sh
steps:
- kubectl:
name: delete secret
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: delete secret wrelease -n=$WERCKER_APPLICATION_OWNER_NAME; echo delete registry secret
- kubectl:
name: create secret
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: create secret docker-registry wrelease --docker-server=wcr.io --docker-username=$WERCKER_APPLICATION_OWNER_NAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL -n=$WERCKER_APPLICATION_OWNER_NAME
deploy-to-cluster:
box:
id: alpine
cmd: /bin/sh
steps:
- bash-template
- kubectl:
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: delete namespace $WERCKER_APPLICATION_OWNER_NAME --ignore-not-found=true
- script:
name: wait to delete namespace
code: sleep 30
- kubectl:
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: create namespace $WERCKER_APPLICATION_OWNER_NAME
- kubectl:
name: create secret
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: create secret docker-registry wrelease --docker-server=wcr.io --docker-username=$WERCKER_APPLICATION_OWNER_NAME --docker-password=$DOCKER_PASSWORD --docker-email=${WERCKER_APPLICATION_OWNER_NAME}@mail.com --namespace=$WERCKER_APPLICATION_OWNER_NAME
- kubectl:
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: create -f $WERCKER_ROOT/kubernetes-deployment.yml --namespace=$WERCKER_APPLICATION_OWNER_NAME
- kubectl:
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: create -f $WERCKER_ROOT/ingress.yml --namespace=$WERCKER_APPLICATION_OWNER_NAME
testapp:
steps:
- script:
name: Run and Test microservice
code: |
java -jar /pipeline/source/target/loan-0.1.0.war &
sleep 10
CREDITSCORE_URL=http://localhost:8080/creditscore
echo 'Microservice URL=' $CREDITSCORE_URL
if curl -X POST -H "Content-Type: application/json" -X POST -d '{"firstname":"John","lastname":"Doe","dateofbirth":"01/01/2015","ssn":"111223333"}' $CREDITSCORE_URL | grep "score: 616"
then
# if the keyword is in the content
echo "Test passed"
else
echo "Test failed"
exit -1
fi
restart:
steps:
# Restart Docker on OCCS using webhook
- script:
name: curl POST
code: curl -k -X POST $DEPLOYMENT_WEBHOOK
deploy-to-weblogic:
box:
id: spotify/alpine
cmd: /bin/sh
steps:
# Deploy WAR using WebLogic RESTManagement interface
- script:
name: Print Wercker public IP
code: curl icanhazip.com
- script:
name: using curl to deploy through REST management interface
code: |
curl -v --user $WLS_ADMIN:$WLS_PASSWORD -H "X-Requested-By:Wercker" -H "Accept:application/json" -H "Content-Type:multipart/form-data" -F "model={name: '${WERCKER_APPLICATION_OWNER_NAME}-webapp', targets: [ 'cluster-1' ]}" -F deployment=@"${WERCKER_ROOT}/target/loan-0.1.0.war" http://${WLS_IP}:${WLS_ADMIN_PORT}/management/wls/latest/deployments/application
- script:
name: Print application URL
code: echo http://${WLS_IP}:30305/${WERCKER_APPLICATION_OWNER_NAME}