mirror of
https://github.com/bvanroll/cicdTest.git
synced 2025-08-29 20:12:43 +00:00
housekeeping
This commit is contained in:
32
manifests/Tekton/tasks/build-and-push.yaml
Normal file
32
manifests/Tekton/tasks/build-and-push.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: build-and-push
|
||||
spec:
|
||||
params:
|
||||
- name: context
|
||||
description: The path to the build context, used by Kaniko - within the workspace
|
||||
default: .
|
||||
type: string
|
||||
- name: image-name
|
||||
description: dockerhub url
|
||||
type: string
|
||||
- name: version
|
||||
description: image-version (for instance latest or beta)
|
||||
type: string
|
||||
workspaces:
|
||||
- name: source
|
||||
mountpath: /source
|
||||
steps:
|
||||
- name: build-and-push
|
||||
image: gcr.io/kaniko-project/executor
|
||||
env:
|
||||
- name: "DOCKER_CONFIG"
|
||||
value: "/tekton/home/.docker/"
|
||||
command:
|
||||
- /kaniko/executor
|
||||
args:
|
||||
- "--dockerfile=/source/$(params.context)/dockerfile"
|
||||
- "--destination=beppev/$(params.image-name):$(params.version)"
|
||||
- "--context=/source/$(params.context)/"
|
51
manifests/Tekton/tasks/create-webhook.yaml
Normal file
51
manifests/Tekton/tasks/create-webhook.yaml
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: create-webhook
|
||||
#namespace: stage-tekton-pipeline
|
||||
spec:
|
||||
volumes:
|
||||
- name: github-secret
|
||||
secret:
|
||||
secretName: $(inputs.params.GitHubSecretName)
|
||||
inputs:
|
||||
params:
|
||||
- name: ExternalDomain
|
||||
description: "The external domain for the EventListener e.g. `$(inputs.params.EventListenerName).<PROXYIP>.nip.io`"
|
||||
- name: GitHubUser
|
||||
description: "The GitHub user"
|
||||
- name: GitHubRepo
|
||||
description: "The GitHub repo where the webhook will be created"
|
||||
- name: GitHubOrg
|
||||
description: "The GitHub organization where the webhook will be created"
|
||||
- name: GitHubSecretName
|
||||
description: "The Secret name for GitHub access token. This is always mounted and must exist"
|
||||
- name: GitHubAccessTokenKey
|
||||
description: "The GitHub access token key name"
|
||||
- name: GitHubSecretStringKey
|
||||
description: "The GitHub secret string key name"
|
||||
- name: GitHubDomain
|
||||
description: "The GitHub domain. Override for GitHub Enterprise"
|
||||
default: "github.com"
|
||||
- name: WebhookEvents
|
||||
description: "List of events the webhook will send notifications for"
|
||||
default: '[\"push\",\"pull_request\"]'
|
||||
steps:
|
||||
- name: create-webhook
|
||||
image: pstauffer/curl:latest
|
||||
volumeMounts:
|
||||
- name: github-secret
|
||||
mountPath: /var/secret
|
||||
command:
|
||||
- sh
|
||||
args:
|
||||
- -ce
|
||||
- |
|
||||
set -e
|
||||
echo "Create Webhook"
|
||||
if [ $(inputs.params.GitHubDomain) = "github.com" ];then
|
||||
curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks
|
||||
else
|
||||
curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://$(inputs.params.GitHubDomain)/api/v3/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks
|
||||
fi
|
24
manifests/Tekton/tasks/execute-yaml.yaml
Normal file
24
manifests/Tekton/tasks/execute-yaml.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: execute-yaml
|
||||
#namespace: stage-tekton-pipeline
|
||||
spec:
|
||||
params:
|
||||
- name: yaml-location
|
||||
default: deploy.yaml
|
||||
- name: command
|
||||
default: apply
|
||||
workspaces:
|
||||
- name: source
|
||||
mountpath: /source
|
||||
steps:
|
||||
- name: deploy-new-app
|
||||
image: lachlanevenson/k8s-kubectl
|
||||
command: ["kubectl"]
|
||||
args:
|
||||
- "$(params.command)"
|
||||
- "-f"
|
||||
- "/source/$(params.yaml-location)"
|
72
manifests/Tekton/tasks/git-clone.yaml
Normal file
72
manifests/Tekton/tasks/git-clone.yaml
Normal file
@@ -0,0 +1,72 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: git-clone
|
||||
spec:
|
||||
workspaces:
|
||||
- name: output
|
||||
description: workspace the repo will be cloned into
|
||||
params:
|
||||
- name: url
|
||||
description: git url to clone
|
||||
type: string
|
||||
- name: revision
|
||||
description: git revision to checkout (branch, tag, sha, ref…)
|
||||
type: string
|
||||
default: master
|
||||
- name: submodules
|
||||
description: defines if the resource should initialize and fetch the submodules
|
||||
type: string
|
||||
default: "true"
|
||||
- name: depth
|
||||
description: performs a shallow clone where only the most recent commit(s) will be fetched
|
||||
type: string
|
||||
default: "1"
|
||||
- name: sslVerify
|
||||
description: defines if http.sslVerify should be set to true or false in the global git config
|
||||
type: string
|
||||
default: "true"
|
||||
- name: subdirectory
|
||||
description: subdirectory inside the "output" workspace to clone the git repo into
|
||||
type: string
|
||||
default: "src"
|
||||
- name: deleteExisting
|
||||
description: clean out the contents of the repo's destination directory (if it already exists) before trying to clone the repo there
|
||||
type: string
|
||||
default: "true"
|
||||
results:
|
||||
- name: commit
|
||||
description: The precise commit SHA that was fetched by this Task
|
||||
steps:
|
||||
- name: clone
|
||||
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:latest
|
||||
script: |
|
||||
CHECKOUT_DIR="$(workspaces.output.path)"
|
||||
cleandir() {
|
||||
if [[ -d "$CHECKOUT_DIR" ]] ; then
|
||||
rm -rf "$CHECKOUT_DIR"/*
|
||||
rm -rf "$CHECKOUT_DIR"/.[!.]*
|
||||
rm -rf "$CHECKOUT_DIR"/..?*
|
||||
fi
|
||||
}
|
||||
if [[ "$(inputs.params.deleteExisting)" == "true" ]] ; then
|
||||
cleandir
|
||||
ls -lah "$CHECKOUT_DIR"
|
||||
fi
|
||||
/ko-app/git-init \
|
||||
-url "$(inputs.params.url)" \
|
||||
-revision "$(inputs.params.revision)" \
|
||||
-path "$CHECKOUT_DIR" \
|
||||
-sslVerify "$(inputs.params.sslVerify)" \
|
||||
-submodules "$(inputs.params.submodules)" \
|
||||
-depth "$(inputs.params.depth)"
|
||||
cd "$CHECKOUT_DIR"
|
||||
RESULT_SHA="$(git rev-parse HEAD | tr -d '\n')"
|
||||
EXIT_CODE="$?"
|
||||
if [ "$EXIT_CODE" != 0 ]
|
||||
then
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
# Make sure we don't add a trailing newline to the result!
|
||||
echo -n "$RESULT_SHA" > $(results.commit.path)
|
Reference in New Issue
Block a user