{"id":28454214,"url":"https://github.com/codewithmuh/jenkins-dockerhub-aws-ecr","last_synced_at":"2026-04-04T22:33:45.676Z","repository":{"id":297419965,"uuid":"996695912","full_name":"codewithmuh/jenkins-dockerhub-aws-ecr","owner":"codewithmuh","description":"Multi-Registry(dockerhub + ECR) Docker CI/CD Pipeline with Jenkins","archived":false,"fork":false,"pushed_at":"2025-06-05T10:49:25.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-28T06:36:45.878Z","etag":null,"topics":["aws","docker","dockerhub","github","jenkins"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codewithmuh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-05T10:21:52.000Z","updated_at":"2025-06-05T10:49:26.000Z","dependencies_parsed_at":"2025-06-05T11:44:11.736Z","dependency_job_id":null,"html_url":"https://github.com/codewithmuh/jenkins-dockerhub-aws-ecr","commit_stats":null,"previous_names":["codewithmuh/jenkins-dockerhub-aws-ecr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codewithmuh/jenkins-dockerhub-aws-ecr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fjenkins-dockerhub-aws-ecr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fjenkins-dockerhub-aws-ecr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fjenkins-dockerhub-aws-ecr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fjenkins-dockerhub-aws-ecr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codewithmuh","download_url":"https://codeload.github.com/codewithmuh/jenkins-dockerhub-aws-ecr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fjenkins-dockerhub-aws-ecr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31416776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","docker","dockerhub","github","jenkins"],"created_at":"2025-06-06T19:00:27.394Z","updated_at":"2026-04-04T22:33:45.646Z","avatar_url":"https://github.com/codewithmuh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐳 Jenkins Docker CI/CD Pipeline – Multi-Registry + Trivy Scan\n\nThis project demonstrates a **Jenkins-based CI/CD pipeline** to:\n\n- ✅ Build Docker images  \n- 📦 Push to **DockerHub** and **AWS ECR**  \n- 🔍 Scan images using **Trivy**  \n- 📧 Send email notifications with scan reports  \n\n---\n\n---\n\n## ✅ Prerequisites\n\nMake sure you have the following:\n\n- Jenkins installed with Docker on the same host\n- Jenkins user added to the `docker` group\n- AWS CLI installed on Jenkins machine\n- Jenkins plugins:\n  - Pipeline\n  - Docker Pipeline\n  - Email Extension\n- Jenkins Credentials:\n  - `dockerhub-creds`: DockerHub username/password\n  - `aws-access-key`, `aws-secret-key`\n  - `smtp-email` (for sending scan reports)\n\n---\n\n## 🧪 Jenkinsfile Pipeline\n\n```groovy\npipeline {\n  agent any\n\n  environment {\n    IMAGE_NAME = \"myapp\"\n    IMAGE_TAG = \"\"\n    AWS_REGION = \"us-east-1\"\n    ECR_REPO = \"\u003caws_account_id\u003e.dkr.ecr.${AWS_REGION}.amazonaws.com/myapp\"\n  }\n\n  stages {\n    stage('Checkout') {\n      steps {\n        checkout scm\n        script {\n          IMAGE_TAG = sh(script: \"git rev-parse --short HEAD\", returnStdout: true).trim()\n        }\n      }\n    }\n\n    stage('Build Docker Image') {\n      steps {\n        sh \"\"\"\n          docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .\n        \"\"\"\n      }\n    }\n\n    stage('Push to DockerHub') {\n      steps {\n        withCredentials([usernamePassword(credentialsId: 'dockerhub-creds', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {\n          sh \"\"\"\n            echo \"${DOCKER_PASS}\" | docker login -u \"${DOCKER_USER}\" --password-stdin\n            docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_TAG}\n            docker push ${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_TAG}\n          \"\"\"\n        }\n      }\n    }\n\n    stage('Push to AWS ECR') {\n      steps {\n        withCredentials([\n          string(credentialsId: 'aws-access-key', variable: 'AWS_ACCESS_KEY_ID'),\n          string(credentialsId: 'aws-secret-key', variable: 'AWS_SECRET_ACCESS_KEY')\n        ]) {\n          sh \"\"\"\n            aws configure set aws_access_key_id ${AWS_ACCESS_KEY_ID}\n            aws configure set aws_secret_access_key ${AWS_SECRET_ACCESS_KEY}\n            aws configure set default.region ${AWS_REGION}\n\n            aws ecr get-login-password --region ${AWS_REGION} | \\\n              docker login --username AWS --password-stdin ${ECR_REPO}\n\n            docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${ECR_REPO}:${IMAGE_TAG}\n            docker push ${ECR_REPO}:${IMAGE_TAG}\n          \"\"\"\n        }\n      }\n    }\n\n    stage('Scan Image with Trivy') {\n      steps {\n        sh \"\"\"\n          apt-get update \u0026\u0026 apt-get install wget apt-transport-https gnupg lsb-release -y\n          wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | apt-key add -\n          echo \"deb https://aquasecurity.github.io/trivy-repo/deb \\$(lsb_release -sc) main\" | \\\n            tee -a /etc/apt/sources.list.d/trivy.list\n          apt-get update \u0026\u0026 apt-get install trivy -y\n\n          docker pull ${IMAGE_NAME}:${IMAGE_TAG}\n          trivy image --format json -o trivy-report.json ${IMAGE_NAME}:${IMAGE_TAG}\n        \"\"\"\n      }\n    }\n\n    stage('Send Email Report') {\n      steps {\n        mail bcc: '',\n             body: 'Docker image scan report attached.',\n             from: 'jenkins@example.com',\n             replyTo: '',\n             subject: \"Trivy Scan Report: ${IMAGE_NAME}:${IMAGE_TAG}\",\n             to: 'your-team@example.com',\n             attachmentsPattern: 'trivy-report.json'\n      }\n    }\n  }\n\n  post {\n    always {\n      cleanWs()\n    }\n  }\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmuh%2Fjenkins-dockerhub-aws-ecr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewithmuh%2Fjenkins-dockerhub-aws-ecr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmuh%2Fjenkins-dockerhub-aws-ecr/lists"}