Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

rockdev24/springbootapp

Open more actions menu
 
 

Repository files navigation

Spring Boot Application Jenkins Pipeline

This Jenkinsfile is designed to build, push, and deploy a Spring Boot application using Docker. Before using this Jenkinsfile in your project, please follow the instructions below to customize it based on your project and DockerHub configuration.

Instructions:

  1. Clone Repository:

    • Ensure that your Jenkins pipeline has the necessary permissions to access your source code repository.
    • Update the scm section in the Jenkinsfile with the correct repository URL if needed.
    stage('Clone repository') {
        checkout scm
    }
  2. Build Image:

    • Set the correct values for the application and dockerhubaccountid variables.
    • Update the Docker image version or tag based on your versioning strategy.
    stage('Build image') {
        def application = "your-spring-boot-app"
        def dockerhubaccountid = "your-dockerhub-account"
        app = docker.build("${dockerhubaccountid}/${application}:${BUILD_NUMBER}")
    }
  3. Push Image:

    • Set the correct DockerHub credentials ID in the credentialsId field.
    • Update the DockerHub registry URL if needed.
    stage('Push image') {
        withDockerRegistry([ credentialsId: "your-dockerhub-credentials-id", url: "your-dockerhub-url" ]) {
            app.push()
            app.push("latest")
        }
    }
  4. Deploy:

    • Update the Docker run command with the correct port mapping, volume mapping, and image version.
    stage('Deploy') {
        sh ("docker run -d -p 82:8080 -v /var/log/:/var/log/ ${dockerhubaccountid}/${application}:${BUILD_NUMBER}")
    }
  5. Remove Old Images:

    • Update the Docker image reference to remove old images.
    stage('Remove old images') {
        sh("docker rmi ${dockerhubaccountid}/${application}:latest -f")
    }
  6. Credentials in Jenkins:

    • Ensure that DockerHub credentials are configured in Jenkins and the correct credentials ID is used in the Jenkinsfile.
  7. Pipeline Execution:

    • Run the Jenkins pipeline and monitor the build process.

Note: Ensure that Docker is properly configured on the Jenkins server and that the Jenkins user has the necessary permissions to interact with Docker.

For additional information on Jenkins pipelines, Docker, and Spring Boot, refer to the documentation for each respective tool.


Replace placeholders like `"your-spring-boot-app"`, `"your-dockerhub-account"`, `"your-dockerhub-credentials-id"`, and `"your-dockerhub-url"` with your actual values. Additionally, review and customize other sections based on your project's requirements.

About

springbootapp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 60.6%
  • HTML 38.3%
  • Other 1.1%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.