I am doing 100 days Devops training and I am stuck on Day 34: Git Hook
Steps I am following
vi /opt/apps.git/hooks/post-update
#!/usr/bin/bash
for ref in "$@";
do
if [ "$ref" = "refs/heads/master" ];
then
TAG_NAME="release-$(TZ="America/Chicago" date +%F)"
git tag -a "$TAG_NAME" -m "Automated release for TODAY" "$ref"
echo "Remote: Tag created $TAG_NAME"
fi
done
exec git update-server-info
cd /usr/src/kodekloudrepos/apps/
git checkout master
git merge feature
git push
Successfully verified created Tag in master branch name.
Everything looks good but I am not able to figure it out what might be the problem! see if anyone is able to come up with the solution… Thank you
I am doing 100 days Devops training and I am stuck on Day 34: Git Hook
Steps I am following
vi /opt/apps.git/hooks/post-update
#!/usr/bin/bash
for ref in "$@";
do
if [ "$ref" = "refs/heads/master" ];
then
TAG_NAME="release-$(TZ="America/Chicago" date +%F)"
git tag -a "$TAG_NAME" -m "Automated release for TODAY" "$ref"
echo "Remote: Tag created $TAG_NAME"
fi
done
exec git update-server-info
cd /usr/src/kodekloudrepos/apps/
git checkout master
git merge feature
git push
Successfully verified new created Tag in master branch name.
Everything looks good but I am not able to figure it out what might be the problem! see if anyone is able to come up with the solution… Thank you
Creating a light-weight tag should work instead of the annotated tag, check the difference between them here.
I’ve seen quite a few users raise similar issue, I guess it is supposed to be specified in the question.
In short creating a tag like below should work. git tag "$TAG_NAME"
#!/bin/bash
echo "Starting post-update hook"
for refname in "$@"; do
echo "Processing ref: $refname"
if [[ "$refname" == "refs/heads/master" ]]; then
echo "Creating tag for release"
TODAY=$(date +%F)
git tag "release-$TODAY" -m "Automated release tag for $TODAY"
else
echo "No action for ref: $refname"
fi
done
echo "Post-update hook completed"
exit 0
Hello guys, i tried with this script and not working.
Previously i tried with git tag -a and later i found this post and try again with git tag “$MSG” but still not working for me.
#!/usr/bin/bash
for ref in "$@";
do
if [ "$ref" = "refs/heads/master" ];
then
### remove this if you feel = TZ="America/Chicago"
TAG_NAME="release-$(TZ="America/Chicago" date +%F)"
git tag "$TAG_NAME"
echo "Remote: Tag created $TAG_NAME"
fi
done
exec git update-server-info
Try not to give too much values to git tag, keep it simple something like: git tag “$TAG_NAME”
We’re about to update the task, in the next day or so. But one thing I’d say to remove from your script: “git update-server-info” should be unneeded, might be harmful in this case.