dont forget to add passwords to build-maven task next update

This commit is contained in:
2020-03-19 12:52:55 +01:00
parent 54710dc73f
commit 3151d8cd5f
3 changed files with 162 additions and 40 deletions

View File

@@ -1,38 +1,113 @@
# ---
# apiVersion: tekton.dev/v1beta1
# kind: Pipeline
# metadata:
# name: stage-application-pipeline
# namespace: tekton-pipeline-1
# spec:
# params:
# - name: git-repo-full-name
# description: full name of the github repo (used for status updates)
# - name: sha
# description: used for github status updates
# - name: git-repo-name
# description: name of the git repo (used to determine the name of the image)
# - name: git-url
# description: url of the git repository to clone
# - name: revision
# description: revision to checkout
# - name: branch
# description: name of the branch to checkout
# workspaces:
# - name: workspace
# tasks:
# - name: clone
# taskRef:
# name: git-clone
# workspaces:
# - name: output
# workspace: workspace
# params:
# - name: url
# value: $(params.git-url)
# - name: revision
# value: $(params.revision)
# - name: build-gradle
# taskRef:
# name: build-image
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: stage-application-pipeline
namespace: tekton-pipeline-1
spec:
params:
- name: git-repo-full-name
description: full name of the github repo (used for status updates)
- name: git-repo-name
description: name of the git repo (used to determine the name of the image)
- name: git-url
description: url of the git repository to clone
- name: revision
description: revision to checkout
- name: branch
description: name of the branch to checkout
workspaces:
- name: workspace
tasks:
- name: clone
taskRef:
name: git-clone
workspaces:
- name: output
workspace: workspace
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.revision)
- name: set-begun-status
taskRef:
name: github-set-status
runAfter:
- clone
params:
- name: REPO_FULL_NAME
value: $(params.git-repo-full-name)
- name: SHA
value: $(params.revision)
- name: TARGET_URL
value: tekton.llocal.host/dashboard
- name: STATE
value: pending
- name: DESCRIPTION
value: "Build of maven file has started"
- name: build-and-push-maven
taskRef:
name: build-maven
runAfter:
- clone
params:
- name: image-name
value: $(params.git-repo-name)
- name: image-tag
value: $(params.branch)
workspaces:
- name: output
workspace: workspace
- name: set-build-finshed-status
taskRef:
name: github-set-status
runAfter:
- build-and-push-maven
params:
- name: REPO_FULL_NAME
value: $(params.git-repo-full-name)
- name: SHA
value: $(params.revision)
- name: TARGET_URL
value: tekton.llocal.host/dashboard
- name: STATE
value: pending
- name: DESCRIPTION
value: "build and push has finished, now starting deployment"
- name: deploy-app
taskRef:
name: deploy-app
runAfter:
- build-and-push-maven
workspaces:
- name: source
workspace: workspace
params:
- name: deploy-name
value: "$(params.git-repo-name)"
- name: deploy-version
value: "$(params.branch)"
- name: set-deploy-finished-status
taskRef:
name: github-set-status
runAfter:
- deploy-app
params:
- name: REPO_FULL_NAME
value: $(params.git-repo-full-name)
- name: SHA
value: $(params.revision)
- name: TARGET_URL
value: tekton.llocal.host/dashboard
- name: STATE
value: success
- name: DESCRIPTION
value: "deploy finished"

View File

@@ -0,0 +1,49 @@
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: build-maven
namespace: tekton-pipeline-1
spec:
params:
- name: DIRECTORY
description: The directory containing the app, relative to the source repository root
default: .
- name: CACHE
description: The name of the volume for caching Maven artifacts and base image layers
default: empty-dir-volume
- name: INSECUREREGISTRY
description: Whether to allow insecure registry
default: "true"
- name: image-name
description: name of the image after push
- name: image-tag
description: tag of the image after push
workspaces:
- name: source
mountpath: /source
steps:
- name: build-and-push
image: gcr.io/cloud-builders/mvn
command:
- mvn
- -B
- compile
- com.google.cloud.tools:jib-maven-plugin:build
- -Duser.home=/tekton/home
- -Djib.allowInsecureRegistries=$(params.INSECUREREGISTRY)
- -Djib.to.image=docker.io/beppev/$(params.image-name):$(params.image-tag)
- -Djib.from.auth.username=
- -Djib.from.auth.password=
- -Djib.from.auth.username=
- -Djib.from.auth.password=
workingDir: /source/$(params.DIRECTORY)
volumeMounts:
- name: $(params.CACHE)
mountPath: /tekton/home/.m2
subPath: m2-cache
- name: $(params.CACHE)
mountPath: /tekton/home/.cache
subPath: jib-cache
volumes:
- name: empty-dir-volume
emptyDir: {}

View File

@@ -42,7 +42,5 @@ spec:
value: $(params.gitreponame)
- name: revision
value: $(params.gitrevision)
- name: sha
value: $(params.sha)
- name: git-repo-full-name
value: $(params.gitrepofullname)