Git hook error: release tag was not created from the master branch - Day 34

I am doing 100 days Devops training and I am stuck on Day 34: Git Hook

Steps I am following

  1. 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
    
  2. cd /usr/src/kodekloudrepos/apps/

  3. git checkout master

  4. git merge feature

  5. git push

  6. 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 :grinning:

I am doing 100 days Devops training and I am stuck on Day 34: Git Hook

Steps I am following

  1. 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
    
  2. cd /usr/src/kodekloudrepos/apps/

  3. git checkout master

  4. git merge feature

  5. git push

  6. 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 :grinning:

I Tried other people’s solution too, which for them it was working fine, but for me it is constantly giving me same error message.

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"

1 Like

Hi Srikanth, Amazing man!!! IT Worked

Party’s on me, where are you located brother, I tried with git tag “$TAG_NAME”, and it worked superb.

1 Like