{"id":20371554,"url":"https://github.com/atulkamble/jenkins-java-maven-pipeline","last_synced_at":"2025-08-07T04:45:18.904Z","repository":{"id":235038463,"uuid":"788289813","full_name":"atulkamble/jenkins-java-maven-pipeline","owner":"atulkamble","description":"This project provides a comprehensive guide for setting up a Jenkins pipeline to automate the build, test, and deployment processes of a basic Java Maven application. It includes sample Java code, Maven configuration (pom.xml), and a Jenkinsfile to facilitate continuous integration and deployment.","archived":false,"fork":false,"pushed_at":"2024-08-13T09:14:57.000Z","size":23,"stargazers_count":1,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T07:00:04.948Z","etag":null,"topics":["cicd","continuous-delivery","continuous-deployment","continuous-integration","java","jenkins","maven","pipeline"],"latest_commit_sha":null,"homepage":"http://linkedin.com/in/atuljkamble","language":"Shell","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/atulkamble.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}},"created_at":"2024-04-18T06:12:45.000Z","updated_at":"2024-12-06T05:31:25.000Z","dependencies_parsed_at":"2024-04-22T04:03:52.470Z","dependency_job_id":null,"html_url":"https://github.com/atulkamble/jenkins-java-maven-pipeline","commit_stats":null,"previous_names":["atulkamble/simple-java-maven-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fjenkins-java-maven-pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fjenkins-java-maven-pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fjenkins-java-maven-pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fjenkins-java-maven-pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atulkamble","download_url":"https://codeload.github.com/atulkamble/jenkins-java-maven-pipeline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233994915,"owners_count":18762950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","continuous-delivery","continuous-deployment","continuous-integration","java","jenkins","maven","pipeline"],"created_at":"2024-11-15T01:08:30.773Z","updated_at":"2025-01-15T05:29:41.651Z","avatar_url":"https://github.com/atulkamble.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins Pipeline Setup for Basic Java Maven Application\n\nComprehensive guide to set up a Jenkins pipeline for a basic Java Maven application, including the necessary Java code, `pom.xml`, `Jenkinsfile`, and steps to get everything up and running.\n\n### 1. **Basic Java Code**\n\nCreate a simple Java project with the following file structure:\n\n```\nbasic-java-app/\n│\n├── src/\n│   └── main/\n│       └── java/\n│           └── com/\n│               └── example/\n│                   └── App.java\n│\n├── pom.xml\n└── Jenkinsfile\n```\n\n#### `App.java`\n\n```java\npackage com.example;\n\npublic class App {\n    public static void main(String[] args) {\n        System.out.println(\"Hello, World!\");\n    }\n}\n```\n\n### 2. **Maven Configuration (`pom.xml`)**\n\nCreate a `pom.xml` file in the root directory of your project to define your Maven configuration:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cproject xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/POM/4.0.0\"\u003e\n\n    \u003cmodelVersion\u003e4.0.0\u003c/modelVersion\u003e\n\n    \u003cgroupId\u003ecom.example\u003c/groupId\u003e\n    \u003cartifactId\u003ebasic-java-app\u003c/artifactId\u003e\n    \u003cversion\u003e1.0-SNAPSHOT\u003c/version\u003e\n    \u003cpackaging\u003ejar\u003c/packaging\u003e\n\n    \u003cname\u003eBasic Java Application\u003c/name\u003e\n    \u003cdescription\u003eA basic Java application with Maven\u003c/description\u003e\n\n    \u003cproperties\u003e\n        \u003cmaven.compiler.source\u003e1.8\u003c/maven.compiler.source\u003e\n        \u003cmaven.compiler.target\u003e1.8\u003c/maven.compiler.target\u003e\n    \u003c/properties\u003e\n\n    \u003cdependencies\u003e\n        \u003c!-- Add dependencies here if needed --\u003e\n    \u003c/dependencies\u003e\n\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n                \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e3.8.1\u003c/version\u003e\n                \u003cconfiguration\u003e\n                    \u003csource\u003e1.8\u003c/source\u003e\n                    \u003ctarget\u003e1.8\u003c/target\u003e\n                \u003c/configuration\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n\n\u003c/project\u003e\n```\n\n### 3. **Jenkinsfile**\n\nCreate a `Jenkinsfile` in the root directory of your project to define the Jenkins pipeline:\n\n```groovy\npipeline {\n    agent any\n\n    tools {\n        maven 'Maven 3.8.6' // Ensure this version is configured in Jenkins\n        jdk 'JDK 11'      // Ensure this JDK version is configured in Jenkins\n    }\n\n    stages {\n        stage('Checkout') {\n            steps {\n                // Checkout code from SCM\n                checkout scm\n            }\n        }\n\n        stage('Build') {\n            steps {\n                // Build the project using Maven\n                sh 'mvn clean install'\n            }\n        }\n\n        stage('Test') {\n            steps {\n                // Run unit tests\n                sh 'mvn test'\n            }\n        }\n\n        stage('Package') {\n            steps {\n                // Package the application\n                sh 'mvn package'\n            }\n        }\n\n        stage('Deploy') {\n            steps {\n                // Simple deployment example\n                sh 'echo \"Deploying application...\"'\n                // Example of copying artifacts to a deploy location\n                sh 'cp target/basic-java-app-1.0-SNAPSHOT.jar /path/to/deploy/'\n            }\n        }\n    }\n\n    post {\n        always {\n            // Clean up actions\n            sh 'echo \"Cleaning up...\"'\n        }\n\n        success {\n            // Actions on successful build\n            echo 'Build succeeded!'\n        }\n\n        failure {\n            // Actions on failed build\n            echo 'Build failed!'\n        }\n    }\n}\n```\n\n### 4. **Steps to Set Up and Run the Pipeline**\n\n1. **Set Up Jenkins**:\n   - Install Jenkins and necessary plugins: `Git Plugin`, `Pipeline Plugin`, `Maven Integration Plugin`, and `JDK Tool`.\n\n2. **Configure Tools in Jenkins**:\n   - Go to `Manage Jenkins` \u003e `Global Tool Configuration`.\n   - Add Maven and JDK installations that match the versions specified in the `Jenkinsfile`.\n\n3. **Create a New Jenkins Pipeline Job**:\n   - Open Jenkins and click on `New Item`.\n   - Choose `Pipeline`, enter a name for your job, and click `OK`.\n   - In the `Pipeline` section, select `Pipeline script from SCM`.\n   - Choose `Git` as the SCM and enter your repository URL.\n   - Set `Script Path` to `Jenkinsfile`.\n\n4. **Commit the Code to Your Repository**:\n   - Save the `App.java`, `pom.xml`, and `Jenkinsfile` in the root directory of your repository.\n   - Push the code to your Git repository.\n\n5. **Run the Pipeline**:\n   - Trigger a build in Jenkins to start the pipeline. Jenkins will checkout the code, build, test, package, and deploy your application according to the stages defined in the `Jenkinsfile`.\n\n### Customization\n\n- **Deployment**: Customize the `Deploy` stage based on your actual deployment requirements.\n- **Notifications**: Add additional steps in the `post` section for notifications or alerts.\n\nThis setup will allow Jenkins to automate the build, test, and deployment processes for your basic Java Maven application. Adjust the `Jenkinsfile` and `pom.xml` as needed to fit your specific project requirements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fjenkins-java-maven-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulkamble%2Fjenkins-java-maven-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fjenkins-java-maven-pipeline/lists"}