-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflow_checkout_prod.sh
executable file
·57 lines (45 loc) · 1.42 KB
/
flow_checkout_prod.sh
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
#!/bin/bash
CURL='/usr/bin/curl'
CREDENTIALS='deploy@trifacta.local:deploy'
HOST='http://prod_env_server:3005'
#HOST='http://localhost:3005'
time=$(date +"%d-%m-%y %T")
echo
if (( $# < 4 ));
then
echo "Please call '$0 -f <flow_id> -d <deploy_id>' to run this command"
echo
exit 1
else
while getopts f:d: option
do
case "${option}"
in
f) flow_id=${OPTARG};;
d) deploy_id=${OPTARG};;
esac
done
fi
echo "Flow ID : "$flow_id
echo "Deployment ID : "$deploy_id
# ------------- Checkout last version of the flow flow_id ---------------
git fetch
git checkout origin/master -- flows/flow_$flow_id.zip
echo
ls -ls ./flows/flow_$flow_id.zip
echo
# ------------- Import a flow (zip package) in deployment project ---------------
# Deploy a flow package
ENDPOINT="/v4/deployments/$deploy_id/releases"
# POST : data / "@path-to-flow.zip"
#curl -X POST http://example.com:3005/v4/deployments/3/releases \
# -H 'authorization: Basic YWRtaW5AdHJpZmFjdGEubG9jYWw6YWRtaW4=' \
# -H 'cache-control: no-cache' \
# -H 'content-type: multipart/form-data' \
# -F data=@path/to/flow.zip
echo $CURL --user $CREDENTIALS $HOST$ENDPOINT --header "Content-Type: multipart/form-data" --request POST -F data=@flows/flow_$flow_id.zip
echo
output=$( $CURL --user $CREDENTIALS $HOST$ENDPOINT --header "Content-Type: multipart/form-data" --request POST -F data=@flows/flow_$flow_id.zip)
echo
echo "Deploy result => $output"
echo