Here is a pseudo-code :
wherein "env1" and "env2" are two env variables which I want to use in some definition in the later stage
pipeline {
agent {
.
.
.
environment {
BUILD_CAUSE = getCause(currentBuild)
env1 = (to be set to true when BUILD_CAUSE is Gerritcause and should be set to false when build cause is Timetriggercause)
env2 = "true"
}
stage('use the env'){
steps{
node('master') {
build.useenv("$env1","$env2")
}
}
}
.
.