Install:

On the Jenkins UI click on Jenkins - Manage Jenkis - Manage Plugins - Available filter for user build vars, check the checkbox and click on "install without restart".

This is a samepl Jenkinsfile showing how to use it.

examples/jenkins/builduser.Jenkinsfile

pipeline {
   agent none
   stages {
       stage('example') {
           agent { label 'master' }
           steps {
               script {
                   wrap([$class: 'BuildUser']) {
                       echo "BUILD_USER=${BUILD_USER}"
                       echo "BUILD_USER_FIRST_NAME=${BUILD_USER_FIRST_NAME}"
                       echo "BUILD_USER_LAST_NAME=${BUILD_USER_LAST_NAME}"
                       echo "BUILD_USER_ID=${BUILD_USER_ID}"
                       echo "BUILD_USER_EMAIL=${BUILD_USER_EMAIL}"
                       echo "---"
                       echo "env.BUILD_USER=${env.BUILD_USER}"
                       echo "env.BUILD_USER_FIRST_NAME=${env.BUILD_USER_FIRST_NAME}"
                       echo "env.BUILD_USER_LAST_NAME=${env.BUILD_USER_LAST_NAME}"
                       echo "env.BUILD_USER_ID=${env.BUILD_USER_ID}"
                       echo "env.BUILD_USER_EMAIL=${env.BUILD_USER_EMAIL}"
                   }
               }
           }
       }
   }
}

In order to make the variables available you need to have your code wrapped in:

wrap([$class: 'BuildUser']) {
}

Sometime it is inconvenient to do that for the whole code, so inside the wrapper, you can copy the values to Other variables that can be then accessed outside of the wrapper as well.