Git Product home page Git Product logo

concourse-spring-boot-maven's Introduction

Concourse for Spring Boot & Maven

This is an example Concourse pipeline for a Spring Boot web app built with Maven.

Prerequisites (and versions used):

brew cask install java
brew cask install vagrant
brew cask install virtualbox

Create a Sprint Boot web app

You can use Spring Initializr and download a Spring Boot app with the web dependency.

Or install the Spring Boot CLI:

brew update
brew tap pivotal/tap
brew install springboot

And create a new Spring Boot app from the command line:

spring init concourse-spring-boot-maven --dependencies=web -build=maven

Check the web app runs locally

./mvnw clean spring-boot:run
open http://localhost:8080

Create a Concourse pipeline

Concourse pipelines consist of three primitives: jobs, resources and tasks.

Job

The first job in the pipeline will get the source code and package using Maven.

# ci/jobs.yml

jobs:
- name: package
  plan:
  - get: source-code
    trigger: true
  - task: package
    privileged: true
    file: source-code/ci/tasks/package.yml

Resource

The package job gets source-code, which is a git resource:

# ci/resources.yml

resources:
- name: source-code
  type: git
  source:
    uri: REPLACE_WITH_YOUR_GIT_REPOSITORY_URL
    branch: master

Task

Then it runs the package task:

# ci/tasks/package.yml

platform: linux

image_resource:
  type: docker-image
  source:
    repository: java
    tag: "8"

inputs:
- name: source-code

run:
  path: source-code/ci/tasks/package.sh

Which tells Concourse to:

  • create a linux container
  • using the Java 8 Dockerfile published on Docker Hub
  • add the source-code resource to the container
  • and run the package script in the container
# ci/tasks/package.sh

#!/bin/bash

set -e -u -x

cd source-code/
./mvnw package

Note: there is no need to run ./mvnw clean pacakge because Concourse creates a new container for every task.

Start Concourse lite

The Concourse team provides a lite version that can be run locally:

vagrant init concourse/lite
vagrant up

At the time of writing the version was 0.75.0.

Download the Concourse CLI

open http://192.168.100.4:8080

Download the fly binary from the Concourse, by clicking on the Apple icon.

Then make it executable and put it in your $PATH, for example:

install ~/Downloads/fly /usr/local/bin/fly

Create the Concourse pipeline

Create a new Concourse target for fly called lite and login:

fly --target lite login --concourse-url http://192.168.100.4:8080

Create a Concourse pipeline called spring-boot-maven using the resources and jobs.

fly --target lite set-pipeline --pipeline spring-boot-maven --config <(cat ci/resources.yml ci/jobs.yml)

NB: the resources and jobs can be combined in one file called pipeline.yml. However, separating them into two files is useful as the pipeline grows in size.

Unpause the new pipeline using fly, or click Play in the web UI.

fly --target lite unpause-pipeline --pipeline spring-boot-maven

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.