
GREETING environment variable that prints together with the build number:
- In shell steps and many Pipeline steps use the
${VAR}(dollar-curly) syntax, e.g.${GREETING}. - Inside Groovy Pipeline code you can access the same variables via the
envmap, e.g.env.BUILD_NUMBERor${env.BUILD_NUMBER}in strings.
env.VAR in scripted logic and ${VAR} in step strings to make intent clear.
Secure handling of secrets
When integrating Jenkins with external services (artifact repositories, cloud providers, APIs, databases), never embed secrets directly in job definitions or source-controlled pipeline files. Use Jenkins’ credentials store to manage sensitive data.
Jenkins credentials UI (example):

Plugins may add additional credential types. Credentials are encrypted on the Jenkins controller and referenced in Pipelines by their credential IDs. Give each credential a meaningful, unique ID (for example,
mongo-db-creds).
Binding credentials in pipelines
Use the withCredentials step to fetch and expose credentials only for the lifetime of a block. Example: bind a username/password credential into environment variables and use them in a shell command:
withCredentialslooks up the credential bycredentialsIdand injects the data into the specified environment variables (MONGO_USER,MONGO_PASSWORD) only for the enclosed block.- After the block ends, those environment variables are removed — reducing risk of accidental leakage.
Never print secrets or credentials to logs. Avoid
echo or sh commands that expose MONGO_PASSWORD or any secret in build output. Use credential masking features and avoid storing secrets in plain text.- Use built-in environment variables for job metadata and the
environmentblock or global settings for custom values. - Store all sensitive data in Jenkins Credentials and reference them by ID with
withCredentials. - Prefer runtime binding and limit the scope where secrets are available to reduce exposure.
- Jenkins Credentials Documentation
- withCredentials step (Pipeline Plugin)
- Creating a GitHub personal access token