I'm writing a task to deploy my application to the server. However, I'd like for this task to run only if my current git branch is the master branch. How can I get the current git branch?
gradle-git
approach:
I know there is a gradle-git plugin that has a method getWorkingBranch()
under the task GitBranchList
, but anytime I try to execute
task getBranchName(type: GitBranchList) {
print getWorkingBranch().name
}
I get a "Task has not executed yet" error. I looked at the source and it throws that error when there is no branch set. Does that mean this method doesn't do quite what I think it does? That I need to set the branch somewhere?