{"id":23769476,"url":"https://github.com/hamdiz0/java-maven-app","last_synced_at":"2026-02-17T18:03:58.019Z","repository":{"id":270411479,"uuid":"875416147","full_name":"hamdiz0/java-maven-app","owner":"hamdiz0","description":"A simple java app built ,packaged ,containerized and deployed all automted with a CI/CD pipline using jenkins , maven, docker and an on premesis kubernetes cluster setup with kubeadm using vagrant and virtualbox","archived":false,"fork":false,"pushed_at":"2025-01-03T01:48:46.000Z","size":519,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-12T09:07:47.474Z","etag":null,"topics":["cicd","devops","docker","java","jenkins","kubernetes","maven","vagrant"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hamdiz0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-19T23:08:10.000Z","updated_at":"2025-11-21T20:57:21.000Z","dependencies_parsed_at":"2025-09-05T13:32:57.349Z","dependency_job_id":"0df48ac0-6c42-461d-9395-efc93238a591","html_url":"https://github.com/hamdiz0/java-maven-app","commit_stats":null,"previous_names":["hamdiz0/java-maven-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hamdiz0/java-maven-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamdiz0%2Fjava-maven-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamdiz0%2Fjava-maven-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamdiz0%2Fjava-maven-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamdiz0%2Fjava-maven-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hamdiz0","download_url":"https://codeload.github.com/hamdiz0/java-maven-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamdiz0%2Fjava-maven-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29552252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T17:56:56.811Z","status":"ssl_error","status_checked_at":"2026-02-17T17:56:55.544Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["cicd","devops","docker","java","jenkins","kubernetes","maven","vagrant"],"created_at":"2025-01-01T02:21:03.831Z","updated_at":"2026-02-17T18:03:58.013Z","avatar_url":"https://github.com/hamdiz0.png","language":"Groovy","readme":"# Java-Maven-App\n\nA simple java app built ,packaged ,containerized and deployed all automted with a CI/CD pipline using jenkins , maven, docker and an on premesis kubernetes cluster setup with kubeadm using vagrant and virtualbox\n\n- [Prerequisites](#prerequisites-)\n- [Architecture](#architecture-)\n- [Infrastructure and Tools](#infrastructure-and-tools-)\n    - [Setting up a Kubernetes cluster](#setting-up-a-kubernetes-cluster-)\n    - [Setting up Jenkins](#setting-up-jenkins)\n- [YAML files](#yaml-files-)\n- [CI/CD Pipeline](#cicd-pipeline)\n  - [CI Pipeline](#ci-pipeline-)\n    - [Building, Packaging, and Versioning the App](#building-packaging-and-versioning-the-app-)\n    - [Building \u0026 Pushing Docker Images](#building--pushing-docker-images-)\n    - [Changing the YAML Files Image Version](#changing-the-yaml-files-iamge-verion-)\n    - [Pushing the Version Change](#pushing-the-version-change-)\n  - [CD Pipeline](#cd-pipeline-)\n- [Results](#results-)\n\n## Prerequisites :\n* Jenkins (as a container)\n* Docker\n* Git/Github\n* Kubernetes\n\n## Architecture :\n\n\u003cimg src='./img/jma.png' style='width:100%'\u003e\n\n## Infrastructure and Tools :\n\n### Setting up a Kubernetes cluster :\n\n* here is guide on how to setup a k8s cluster with vagrant and kubeadm \u003ca href=\"https://github.com/vancanhuit/vagrant-k8s\"\u003evagrant-k8s\u003c/a\u003e\n\n* here is a minikube quik setup repo \u003ca href=\"https://github.com/hamdiz0/minikube-setup\"\u003eminikube-setup\u003c/a\u003e\n\n### Setting up Jenkins\n\n* follow this guide to set up jenkins as a container \u003ca href=\"https://github.com/hamdiz0/LearningDevOps/blob/main/jenkins/README.md#doker-in-jenkins\"\u003eDocker in Jenkins\u003c/a\u003e\n\n* make sure docker is setup in jenkins (more details \u003ca href=\"https://github.com/hamdiz0/Learning-DevOps/tree/main/jenkins#doker-in-jenkins\"\u003ehere\u003c/a\u003e)\n\n* it's preferable to use a multibranch pipeline cause of the usefull plugins and features it provides\n\n* make sure maven is installed and configured in jenkins \n\n\u003cimg src='./img/mvn.png' style='width:100%'\u003e\n\n* add \"Multibranch Scan Webhook Trigger\" plugin in jenkins \n\n\u003cimg src='./img/trigger.png' style='width:100%'\u003e\n\n* configure a webhook in the git repo webhook settings :\n    - `\u003cjenkins-url\u003e/multibranch-webhook-trigger/invoke?token=\u003ctoken\u003e`\n\n* more details about multibranch webhooks \u003ca href=\"https://github.com/hamdiz0/Learning-DevOps/blob/main/jenkins/README.md#multibranch-triggers-\"\u003ehere\u003c/a\u003e\n\n* cofingure the connection to the k8s cluster in jenkins using the kubeconfig file\n    - in the kubernetes master node retrive the kubeconfig file content :\n        ```bash\n        kubectl config view --raw\n        ```\n    - create a file in the jenkins container and paste the content of the kubeconfig file in it :\n        ```bash\n        docker exec -it jenkins bash\n        ```\n        ```bash\n        nano /kubecfg/config\n        ```\n* note that the certicates and keys must be the actual data not just paths pointing to the files containing it, this is specificly for minikube \n\n## YAML files :\n\n* set up a deployment for the app along with a ClusterIP service to expose it externally :\n    - view the \u003ca href=\"k8s-manifests/deployment.yml\"\u003edeployment.yml\u003c/a\u003e\n    - view the \u003ca href=\"k8s-manifests/service.yml\"\u003eservice.yml\u003c/a\u003e\n\n\n## CI/CD Pipeline\n\n### CI Pipeline :\n\n* the CI pipeline is triggered by a webhook evry time a push is made to the git repo\n\n#### building ,packaging and versioning the app :\n\n* the app is built and packaged using maven\n\n    ```bash\n    mvn clean package   // delete the old version and package the app\n    ```\n\n* than the version is incremented ,in this case the minor version is incremented while the major version is kept the same :\n\n    ```groovy\n    sh 'mvn build-helper:parse-version versions:set \\\n    -DnewVersion=\"\\\\\\${parsedVersion.majorVersion}.\\\\\\${parsedVersion.nextMinorVersion}\" \\\n    versions:commit'\n    // read the new incremented version from pom.xml\n    def match = readFile('pom.xml') =~ '\u003cversion\u003e(.+)\u003c/version\u003e'\n    def version = match[0][1]           // get the first match (application version in pom.xml)\n    env.IMAGE_VERSION = \"$version\"      // set the version environment variable\n    ```\n#### Building \u0026 Pushing docker images :\n\n* utilzed a function to build and push the image to docker hub using the same versioning as the app :\n    - view the funtcion \u003ca href=\"./script.groovy\"\u003ehere\u003c/a\u003e\n    - example :\n        ```\n        gs.image_build(\n            'hamdiz0/java-maven-app',   // image name\n            IMAGE_VERSION,              // version\n            'docker-repo',              // credentailsID for DockerHub in jenkins\n            '.'                         // dockerfile location in the git repo\n        )\n        ```\n\n#### Changing the YAML files iamge verion :\n\n* utilized a script to change the demployment image version \u003ca href=\"./k8s-manifests/change_version.sh\"\u003echange_version.sh\u003c/a\u003e\n* the update_yaml_version function takes the path to the yaml files, the script name and the image version as arguments (the script must be in the same directory as the yaml files) :\n    ```groovy\n    gs.update_yaml_version(\n        \"k8s-manifests\",            // yaml files and script location (same directory)\n        \"change_version.sh\",        // change version script name (.sh)\n        IMAGE_VERSION              \n    )\n    ```\n### Pushing the version change :\n\n* set up jenkins to update the git repository with new version\n* set up a git user.name and user.eamil for jenkins :\n    ```\n    docker exec -it jenkins bash\n    git config --global user.name \"jenkins\"\n    git config user.email \"jenkins@jenkins.com\"\n    ```\n* ustilized a function that adds and push changes to a git repository \n    - view the function \u003ca href=\"./script.groovy\"\u003ehere\u003c/a\u003e\n* the function uses a git access token wish must be configured and added to jenkins as a `Username and Password` credential\n    - set up an access token in git hub :\n    \u003cimg src=\"./img/token.PNG\" style=\"width:100%\"\u003e\n* make sure to add the `Ignore Commiter Strategy` plugin and ignore jenkins pushes to avoid infinite build loops :\n    \u003cimg src=\"./img/avoid.PNG\" style=\"width:100%\"\u003e\n* example of using the function :\n    ```groovy\n    gs.git_push(\n        'github.com/hamdiz0/java-maven-app.git',    // url without \"https://\"\n        'github-api-token',                         // credentialsId\n        \"updated to version ${IMAGE_VERSION}\",      // commit message\n        'main'                                      // branch\n    )\n    ```\n### CD Pipeline :\n\n* after the \"updated yaml files version\" stage the \"deploy\" stage is triggered \n* the deploy function runs the \u003ca href=\"./k8s-manifests/deploy.sh\"\u003edeploy.sh\u003c/a\u003e script wich applies the changes to the k8s cluster :\n    ```groovy\n    gs.deploy(\n        \"k8s-manifests\",            // yaml files location\n        \"deploy.sh\",                // deployment script name (.sh)\n        KUBECONFIG_PATH,            // kubeconfig absolute path in the jenkins container\n    )\n    ```\n* the function takes three arguments : the path to the yaml files, the script name and the kubeconfig path in the jenkins container\n* the yaml files must be in the same directory as the script\n\n## Results :\n\n\u003cimg src='./img/res1.png' style='width:100%'\u003e\n\u003cimg src='./img/res2.png' style='width:100%'\u003e\n\u003cimg src='./img/res3.png' style='width:100%'\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamdiz0%2Fjava-maven-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamdiz0%2Fjava-maven-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamdiz0%2Fjava-maven-app/lists"}