Jenkins Pipeline project can't when on branch
This is the way to go:

stage('Deploy'){
  when {
    expression {env.GIT_BRANCH == 'origin/master'}
  }
  steps {
    ....
   }
}


Take care, this is only working with the declarative syntax.

The environment step is used to "set up the environment" meaning this is the place to declare environmental variables. 

Also, in my case I did not declare the GIT_BRANCH var myself. But jenkins provides it as an environmental (therefore "env.GIT_BRANCH") variable if you did "checkout scm" to checkout your repository. If you want to check all the available env vars, do this as a step: sh 'printenv'

check out this article for more info: https://jenkins.io/blog/2017/01/19/converting-conditional-to-pipeline/