Created
February 11, 2019 21:59
-
-
Save kelapure/ef79419796e35a68629a4e772e4646e4 to your computer and use it in GitHub Desktop.
The script that executes any batch job on the PCF as a task, waits for the result and prints out associated logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APP_NAME=$1 | |
CMD=$2 | |
task_id=$(cf run-task $APP_NAME "${CMD}" | grep "task id:" | awk '{print $3}') | |
task_name=$(cf tasks $APP_NAME | grep "^$task_id " | awk '{print $2}') | |
task_status=$(cf tasks $APP_NAME | grep "^$task_id " | awk '{print $3}') | |
while [ $task_status = 'RUNNING' ] | |
do | |
sleep 1 | |
task_status=$(cf tasks $APP_NAME | grep "^$task_id " | awk '{print $3}') | |
done | |
cf logs $APP_NAME --recent | grep "TASK/$task_name" | |
exit $([ $task_status = 'SUCCEEDED' ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit to Oleg