Getting Credentials of Current User in Jenkins Pipeline Script Getting Credentials of Current User in Jenkins Pipeline Script jenkins jenkins

Getting Credentials of Current User in Jenkins Pipeline Script


This could work for you

BUILD_CAUSE_JSON=$(curl --silent ${BUILD_URL}/api/json | tr "{}" "\n" | grep "Started by")BUILD_USER_ID=$(echo $BUILD_CAUSE_JSON | tr "," "\n" | grep "userId" | awk -F\" '{print $4}')BUILD_USER_NAME=$(echo $BUILD_CAUSE_JSON | tr "," "\n" | grep "userName" | awk -F\" '{print $4}')