How to override environment variables in Execute Shell

Hi everyone,

I have a Jenkins job that feeds a Mattermost chat channel, with output value returned from a Python script, after each build.

I defined an environment variable under Manage Jenkins → Configure System as following:

enter image description here

In “Execute shell”, I call my script and it returns the relevant value as below.

RET=$(python main.py)

However, I could not override the environment variable SCRIPT_RET with the output value RET above, to use in the custom message with $SCRIPT_RET

Any help is appreciated, thanks!