This Jenkins pipeline script automates OWASP Dependency-Check vulnerability scanning and Docker image building and deployment, with notifications to Discord on success or failure.
Ensure the following are set up before running this pipeline:
- Jenkins with necessary plugins (OWASP Dependency-Check, Docker, SSH)
- Docker Hub credentials configured in Jenkins
- Discord webhook URL for notifications
The pipeline consists of three main stages:
- Checkout: Fetches the source code from the repository.
- OWASP Dependency-Check Vulnerabilities: Runs OWASP Dependency-Check to scan for vulnerabilities.
- Build and Push Docker Image: Builds a Docker image and pushes it to Docker Hub.
- Trigger Deployment: Deploys the Docker image to a remote server via SSH.
Make sure these environment variables are configured in your Jenkins job:
DOCKER_CREDENTIALS_ID
: Jenkins credentials ID for Docker Hub.IMAGE
: Docker image name and tag.NVD_API_KEY
: API key for NVD (National Vulnerability Database).DISCORD_WEBHOOK_URL
: Discord webhook URL for notifications.
-
Configure Jenkins:
- Create a new pipeline job in Jenkins.
- Copy the pipeline script (
Jenkinsfile
) into the job configuration.
-
Run the Pipeline:
- Trigger the pipeline manually or set up automatic triggers based on your repository changes.
-
Monitor and Notifications:
- Jenkins will notify Discord with build and deployment status updates.
Notifications are sent to Discord using a webhook. Customize the Discord webhook URL and icon URL in the sendDiscordNotification
function within the pipeline script.
Feel free to fork this repository and enhance the pipeline script based on your needs. Pull requests are welcome!