I am using Jenkins 2.277 and when trying to create a pipeline script that has GIT_BRANCH or BRANCH_NAME, it's giving null values and I have conditions in the script that checks for master/develop branch and run the script accordingly. Because the GIT environment variables seems to be giving null value, it is not running the script as desired. I have seen online that this was a bug within Jenkins and I saw some workarounds which didn't work for me.
Is this issue still not fixed in Jenkins Pipeline? Is there any solution for this? I am planning to use multibranch pipeline. But wanted to check if there is any existing solution for non-multibranch pipeline in accessing the git environment variables.