Introduction
Sometimes your Jenkins pipeline needs to use secret information like passwords or API keys safely. The WithCredentials block helps you use these secrets in your pipeline without exposing them openly.
When your pipeline needs to access a private Git repository using a username and password.
When you want to deploy to a cloud service that requires an API key stored securely in Jenkins.
When running tests that require database credentials without hardcoding them in your code.
When you want to keep secret tokens safe while using them temporarily in a build step.
When you need to pass SSH keys securely to a shell command during deployment.