Introduction
Sometimes your Jenkins pipeline needs to use specific settings or secrets like API keys or server addresses. The environment directive lets you set these values so your pipeline steps can use them easily.
When you want to set a database URL that your build needs to connect to.
When you need to provide an API token for a deployment step.
When you want to define a common version number used across multiple steps.
When you want to keep sensitive information like passwords out of your script code.
When you want to reuse environment variables in different parts of your pipeline.