Skip to content

Instantly share code, notes, and snippets.

@Thakurvaibhav
Last active February 24, 2023 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thakurvaibhav/a59b0ba6387142d76359039a248adf39 to your computer and use it in GitHub Desktop.
Save Thakurvaibhav/a59b0ba6387142d76359039a248adf39 to your computer and use it in GitHub Desktop.
Updating the nginx conf to depict current app version
#!/bin/bash
#Author: Vaibhav Thakur
#Checking whether commit was in master of not.
if_master=`echo $payload | jq '.ref' | grep master`
if [ $? -eq 1 ]; then
echo "Pipeline should not be triggered"
exit 2
fi
#Getting tag from pom.xml
TAG=`grep SNAPSHOT pom.xml | sed 's|[<,>,/,version ]||g'`
echo $TAG
#Getting action from commit message
ACTION=$(echo $payload | jq -r '.commits[0].message' | cut -d',' -f2)
#Updating index.html
sed -i -- "s/VER/${TAG}/g" app/index.html
#Pushing to dockerhub
docker build -t vaibhavthakur/nginx-demo:$TAG .
docker push vaibhavthakur/nginx-demo:$TAG
echo TAG=${TAG} > trigger.properties
echo ACTION=${ACTION} >> trigger.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment