Variables not set in jenkins pipeline script

hi there,
I wrote a pipeline which is used to build code by docker run, however, i found the variable value cannot be passed to docker. Any help would be appreciated.

pipeline{
agent any
environment {
build_user_id = “11”
}
stages{
stage(‘build_user1’){
steps{
wrap([$class: ‘BuildUser’]) {
script{
env.build_user_id = env.BUILD_USER_ID
sh ‘echo $build_user_id’ # show correctly
sh ‘docker run -e build_user_id=$build_user_id test’ # value of build_user_id is empty
}
}
}
}
}
}

btw you can do just -e build_user_id which will tell docker to pull the variable directly from env.

maybe try docker run --rm -e build_user_id bash printenv so its clear its not your container doing weird things.