Skip to content

Build pipeline in concourse #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ Please refer to the link:CONTRIBUTING.adoc[] for more details.
== License

https://www.apache.org/licenses/LICENSE-2.0[Apache License v2.0]

25 changes: 25 additions & 0 deletions ci/images/ci-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ubuntu:focal-20220801
#
#VOLUME /var/run/docker.sock
#
###########################################################
# JAVA
###########################################################

ADD ./setup.sh /setup.sh
ADD ./get-jdk-url.sh /get-jdk-url.sh
ADD ./get-docker-url.sh /get-docker-url.sh
RUN ./setup.sh java17

ENV JAVA_HOME /opt/openjdk
ENV PATH $PATH:$JAVA_HOME/bin
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

#



#ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]
#ENTRYPOINT ["sh"]
ENTRYPOINT [ "switch", "shell=/bin/bash", "--", "codep", "/bin/docker daemon" ]
22 changes: 22 additions & 0 deletions ci/images/ci-image/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# Copyright 2021 - 2022 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -e

mvn --version

exec "$@"
20 changes: 20 additions & 0 deletions ci/images/ci-image/get-docker-url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
#
# Copyright 2021 - 2022 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e

version="20.10.17"
echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz";
16 changes: 16 additions & 0 deletions ci/images/ci-image/get-jdk-url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

case "$1" in
java17)
echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-amd64.tar.gz"
# echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-aarch64.tar.gz"

;;
java18)
echo "https://github.com/bell-sw/Liberica/releases/download/18.0.2+10/bellsoft-jdk18.0.2+10-linux-amd64.tar.gz"
;;
*)
echo $"Unknown java version"
exit 1
esac
106 changes: 106 additions & 0 deletions ci/images/ci-image/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash
set -ex

###########################################################
# UTILS
###########################################################

export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install --no-install-recommends -y git curl jq tzdata ca-certificates net-tools libxml2-utils git curl libudev1 libxml2-utils iptables iproute2 jq gnupg lsb-release software-properties-common python3-pip
apt-get update
ln -fs /usr/share/zoneinfo/UTC /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
rm -rf /var/lib/apt/lists/*

# curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh > /opt/concourse-java.sh


###########################################################
# JAVA
###########################################################
JDK_URL=$( ./get-jdk-url.sh $1 )

mkdir -p /opt/openjdk
cd /opt/openjdk
curl -L ${JDK_URL} | tar zx --strip-components=1
test -f /opt/openjdk/bin/java
test -f /opt/openjdk/bin/javac

if [[ $# -eq 2 ]]; then
cd /
TOOLCHAIN_JDK_URL=$( ./get-jdk-url.sh $2 )

mkdir -p /opt/openjdk-toolchain
cd /opt/openjdk-toolchain
curl -L ${TOOLCHAIN_JDK_URL} | tar zx --strip-components=1
test -f /opt/openjdk-toolchain/bin/java
test -f /opt/openjdk-toolchain/bin/javac
fi

############################################################
## MAVEN
############################################################

#INSTALL MAVEN
MAVEN_VERSION=3.6.3

# 2- Define a constant with the working directory
USER_HOME_DIR="/root"

# 4- Define the URL where maven can be downloaded from
BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries

# 5- Create the directories, download maven, validate the download, install it, remove downloaded file and set links
mkdir -p /usr/share/maven /usr/share/maven/ref \
&& echo "Downlaoding maven" \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
\
&& echo "Unziping maven" \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
\
&& echo "Cleaning and setting links" \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

# 6- Define environmental variables required by Maven, like Maven_Home directory and where the maven repo is located


###########################################################
# DOCKER
###########################################################
#mkdir -p /etc/apt/keyrings
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
#echo \
# "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
# $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
#sudo apt-get update
#sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
#
#
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
#APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
#apt-key fingerprint 0EBFCD88
#add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
#apt-get update
#apt-cache policy docker-ce
#apt-get -y install docker-ce
#usermod -aG docker root


######

cd /
DOCKER_URL=$( ./get-docker-url.sh )
curl -L ${DOCKER_URL} | tar zx
mv /docker/* /bin/
chmod +x /bin/docker*

export ENTRYKIT_VERSION=0.4.0
curl -L https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz | tar zx
chmod +x entrykit && \
mv entrykit /bin/entrykit && \
entrykit --symlink

# Docker Compose
pip3 install docker-compose
187 changes: 187 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
---
anchors:
git-repo-resource-source: &git-repo-resource-source
uri: ((github-repo-uri)) # https://github.com/spring-projects-experimental/spring-boot-migrator
username: ((github-repo-user)) # fabapp2
password: ((github-ci-release-token))
branch: ((branch))
registry-image-resource-source: &registry-image-resource-source
username: ((docker-hub-username))
password: ((docker-hub-password))
tag: ((milestone))
registry_mirror:
host: ((docker-hub-mirror))
username: ((docker-hub-mirror-username))
password: ((docker-hub-mirror-password))
docker-hub-mirror-vars: &docker-hub-mirror-vars
docker-hub-mirror: ((docker-hub-mirror))
docker-hub-mirror-username: ((docker-hub-mirror-username))
docker-hub-mirror-password: ((docker-hub-mirror-password))

resource_types:
- name: registry-image
type: registry-image
source:
repository: concourse/registry-image-resource
tag: 1.5.0
- name: git-pull-request
type: docker-image
source:
repository: ((github-repo-name))
- name: pull-request
type: registry-image
source:
repository: teliaoss/github-pr-resource
tag: v0.23.0


resources:
# The ci dir in the repo, used to trigger an image build on change
- name: ci-images-git-repo
type: git
icon: github
source:
uri: ((github-repo-uri))
branch: ((branch))
paths: ["ci/images/*"]
# The git repo
- name: git-repo
type: git
icon: github
source:
<<: *git-repo-resource-source
# The image used to run the build
- name: ci-image
type: registry-image
icon: docker
source:
<<: *registry-image-resource-source
repository: fkrueger096/spring-boot-migrator-ci
tag: latest
# branches for multi-branch pipeline
# - name: branches
# type: git-branches
# source:
# uri: ((github-repo-uri))
# branch_regex: '.*'


# git PR
- name: git-pull-request
type: pull-request
icon: source-pull
source:
access_token: ((github-ci-pull-request-token))
repository: ((github-repo-name))
base_branch: main
ignore_paths: [ "ci/*" ]

image_resource:
type: registry-image
source:
repository: concourse/oci-build-task
tag: 0.10.0
registry_mirror:
host: ((docker-hub-mirror))
username: ((docker-hub-mirror-username))
password: ((docker-hub-mirror-password))

jobs:
# Build and push CI image when ci-images-git-repo changed
- name: build-ci-images
plan:
- get: ci-images-git-repo
trigger: true
- get: git-repo
- in_parallel:
- task: build-ci-image
privileged: true
file: git-repo/ci/tasks/build-ci-image.yml
output_mapping:
image: ci-image
vars:
ci-image-name: ci-image
<<: *docker-hub-mirror-vars
- in_parallel:
- put: ci-image
params:
image: ci-image/image.tar

# Build application
- name: build
public: true
plan:
- in_parallel:
- get: ci-image
- get: git-repo
trigger: true
- task: compile
image: ci-image
file: git-repo/ci/tasks/maven-build.yml
# - in_parallel:
# fail_fast: true
# steps:
# - task: run-unit-tests
# image: ci-image
# file: git-repo/ci/tasks/maven-unit-test.yml
# - task: run-integration-tests
# image: ci-image
# file: git-repo/ci/tasks/maven-integration-test.yml

# - name: set-feature-pipelines
# plan:
# - in_parallel:
# - get: feature-branches
# trigger: true
# - get: git-repo
# - load_var: branches
# file: feature-branches/branches.json
# - across:
# - var: branch
# values: ((.:branches))
# set_pipeline: dev
# file: examples/pipelines/multi-branch/template.yml
# instance_vars: {feature: ((.:branch.groups.feature))}
# vars: {branch: ((.:branch.name))}

# Build every new PR
- name: build-pull-requests
serial: true
public: true
plan:
- get: ci-image
- get: git-repo
resource: git-pull-request
trigger: true
version: every
- do:
- put: git-pull-request
params:
path: git-repo
status: pending
- task: build-project
image: ci-image
file: git-repo/ci/tasks/build-pr-project.yml
# timeout: 30m # ((task-timeout))
on_success:
put: git-pull-request
params:
path: git-repo
status: success
on_failure:
put: git-pull-request
params:
path: git-repo
status: failure

groups:
- name: "builds"
jobs: ["build"]
# - name: "releases"
# jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release", "publish-gradle-plugin", "publish-to-sdkman", "update-homebrew-tap"]
# - name: "system-tests"
# jobs: ["run-system-tests", "jdk18-run-system-tests"]
- name: "ci-images"
jobs: ["build-ci-images"]
- name: "pull-requests"
jobs: ["build-pull-requests"]
Loading