-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitbucket-pipelines.yml
93 lines (91 loc) · 5.16 KB
/
bitbucket-pipelines.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
# This is a sample build configuration for Java (Maven).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: maven:3.3.9
options:
max-time: 5
pipelines:
branches:
master:
- step:
name: Build WAR file and save in Downloads.
caches:
- maven
script: # Modify the commands below to build your repository.
- echo version=\${pom.version} > src/main/resources/version.txt
- echo build=${BITBUCKET_BUILD_NUMBER} >> src/main/resources/version.txt
- echo build.date=\${timestamp} >> src/main/resources/version.txt
- echo -n commit= >> src/main/resources/version.txt
- git rev-parse HEAD >> src/main/resources/version.txt
- cat src/main/resources/version.txt
- sed -i "s\baseurl=.*\baseurl=http://appointments.directoryofservices.nhs.uk:443/poc/\g" src/main/resources/server.properties
- sed -i "s\environment=.*\environment=Demonstrator\g" src/main/resources/server.properties
- sed -i "s\capability.softwareversion=.*\capability.softwareversion=${BITBUCKET_BUILD_NUMBER}\g" src/main/resources/server.properties
- mvn -B clean install
- git rev-parse HEAD >> target/classes/version.txt
- curl -X POST "https://${BB_AUTH_STRING}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"target/bookingprovider-2.0-SNAPSHOT.war"
- curl -X POST "https://${BB_AUTH_STRING}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"Dockerfile"
artifacts:
- target/*.war
# Requires a different image, with AWS CLI installed...
- step:
name: Deploy to ECS
deployment: production
image: tstrohmeier/awscli:3.6.4
caches:
- docker
script:
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
- docker build -t a2sibookingprovider .
- docker tag a2sibookingprovider:latest ${AWS_REGISTRY_URL}a2sibookingprovider:latest
- docker push ${AWS_REGISTRY_URL}a2sibookingprovider:latest
- sleep 2
- aws ecs update-service --cluster BookingPOCCluster --service BookDemonstrator --force-new-deployment
# This should put a message into the Teams channel (dodgy characters will need escaping)
- printf "{\"title\":\"Deployment of Care Connect Demonstrator\",\"text\":\"Build number %s is currently being deployed\"}" ${BITBUCKET_BUILD_NUMBER} > teams_announce.json
- curl -X POST "https://outlook.office.com/webhook/${TEAMS_LINK}" --data @teams_announce.json
services:
- docker
# Pipeline for develop branch...
# Removed, to save precious Pipeline minutes for real deployment work.
develop:
- step:
name: Build WAR file.
caches:
- maven
script: # Modify the commands below to build your repository.
- echo DEVELOP RELEASE > src/main/resources/version.txt
- echo version=\${pom.version} >> src/main/resources/version.txt
- echo build=${BITBUCKET_BUILD_NUMBER} >> src/main/resources/version.txt
- echo build.date=\${timestamp} >> src/main/resources/version.txt
- echo -n commit= >> src/main/resources/version.txt
- git rev-parse HEAD >> src/main/resources/version.txt
- cat src/main/resources/version.txt
- sed -i "s\baseurl=.*\baseurl=http://a2sibookingprovidertest.directoryofservices.nhs.uk:443/poc/\g" src/main/resources/server.properties
- sed -i "s\environment=.*\environment=TestDemonstrator\g" src/main/resources/server.properties
- sed -i "s\capability.softwareversion=.*\capability.softwareversion=${BITBUCKET_BUILD_NUMBER}\g" src/main/resources/server.properties
- mvn -B clean install
- git rev-parse HEAD >> target/classes/version.txt
artifacts:
- target/*.war
# Requires a different image, with AWS CLI installed...
- step:
name: Deploy to ECS DEV service
deployment: test
image: tstrohmeier/awscli:3.6.4
caches:
- docker
script:
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
- docker build -t a2sibookingprovidertest .
- docker tag a2sibookingprovidertest:latest ${AWS_REGISTRY_URL}a2sibookingprovidertest:latest
- docker push ${AWS_REGISTRY_URL}a2sibookingprovidertest:latest
- sleep 2
- aws ecs update-service --cluster BookingPOCCluster --service a2sibookingprovidertest --force-new-deployment
# This puts a message into the Teams channel
#- printf "{\"title\":\"Deployment of Care Connect Demonstrator\",\"text\":\"Build number %s is currently being deployed\"}" ${BITBUCKET_BUILD_NUMBER} > teams_announce.json
#- curl -X POST "https://outlook.office.com/webhook/${TEAMS_LINK}" --data @teams_announce.json
services:
- docker