BRANCH=RELEASE \ && cd /opt/build/mcmpgitopsrelease \ && echo "updating build for branch ${BRANCH}..." \ && git fetch --tags \ && echo "git reset branch ${BRANCH}..." \ && git reset --hard \ && git checkout "${BRANCH}" \ && echo "checkout complete for branch ${BRANCH}..." \ && git pull \ && echo "pull complete for ${BRANCH}..." \ && printf '\n' \ && echo "$(date) - updated branch ${BRANCH}..." \ && FORM=$(file='./mcmporders' && \ while read file; do echo $(git log --pretty=format:%ad -n 1 --date=raw -- $file) $file; done < <(git ls-tree -r --name-only HEAD) | sort -k1,1n | awk 'END{print}' | awk '{print $3}') \ && APP=$(cat $FORM | jq '.app') \ && sudo docker stop $APP || true \ && sudo docker rm $APP || true \ && CMD="sudo docker run -d --restart=always -p 80:80 $APP" \ && echo $CMD \ && eval $CMD
#!/bin/bash cd /tmp && rm -rf mcmp-gitops-release && git clone https://mcmpdemo:[email protected]/mcmpdemoeng/mcmp-gitops-release.git \ && BRANCH=RELEASE \ && ls /$WORKSPACE \ && cd /tmp/mcmp-gitops-release \ && ls /tmp/mcmp-gitops-release \ && echo "updating build for branch ${BRANCH}..." \ && git fetch --tags \ && echo "git reset branch ${BRANCH}..." \ && git reset --hard \ && git checkout "${BRANCH}" \ && echo "checkout complete for branch ${BRANCH}..." \ && git pull \ && echo "pull complete for ${BRANCH}..." \ && printf '\n' \ && echo "$(date) - updated branch ${BRANCH}..." \ && FORM=$(file='./mcmporders' && while read -r file; do echo "$(git log --pretty=format:%ad -n 1 --date=raw -- "$file")" "$file"; done < <(git ls-tree -r --name-only HEAD) | sort -k1,1n | awk 'END{print}' | awk '{print $3}') \ && ORDER=$(echo $FORM | cut -d/ -f1) \ && echo "Retreiving parameters for Order# $ORDER" \ && TFSATE=$(cat $FORM | jq '.deployment_status') \ && param1=$(cat $FORM | jq '.param1') \ && param2=$(cat $FORM | jq '.param2') \ && password=$(cat $FORM | jq '.password') \ && echo "Got Terraform State" \ && echo $TFSATE \ && echo "Got user defined configuration parameters" \ && echo $param1 \ && echo $param2 \ && echo $password \ && echo "Got credentials" \ && echo "#####################################################################################" \ && echo "#####################################################################################" \ && echo "Running deployment" \ && echo "You can run shell commands in this job using eval $CMD & use parameters sent by Enterprise Marketplace" \ && echo "set -ex ensures the job errors out if any step fails" \ && set -ex \ && CMD="do_something $param1 $param2" \ && echo $CMD \ && echo "#####################################################################################" \ && echo "App Installation completed..." \ && echo "#####################################################################################" \ && cd /tmp && rm -rf mcmp-gitops-content && git clone https://mcmpdemo:[email protected]/mcmpdemoeng/mcmp-gitops-content.git \ && cd /tmp/mcmp-gitops-content \ && git checkout Orders \ && echo "#####################################################################################" \ && echo "Processing Enterprise Marketplace order updates for Order# $ORDER" \ && echo "#####################################################################################" \ && ORDER=$(echo $FORM | cut -d/ -f1) \ && jq '.status="Completed"' "/tmp/mcmp-gitops-content/mcmporders/$ORDER/orderStatusTracking.json" > "/tmp/mcmp-gitops-content/mcmporders/$ORDER/orderStatusTracking.json.tmp" \ && mv "/tmp/mcmp-gitops-content/mcmporders/$ORDER/orderStatusTracking.json.tmp" "/tmp/mcmp-gitops-content/mcmporders/$ORDER/orderStatusTracking.json" \ && rm -f "/tmp/mcmp-gitops-content/mcmporders/$ORDER/orderStatusTracking.json.tmp" \ && git add -A \ && git add . \ && echo "#####################################################################################" \ && git commit -m "Successfully updated order status for Order# $ORDER" \ && echo "#####################################################################################" \ && git push -u origin Orders \ && echo "App deployment job for Order# $ORDER completed successfully!"