inputs > gewoon params is zo een rare change

This commit is contained in:
2020-03-16 14:13:58 +01:00
parent c7474c0132
commit 51d4dd6f4e
20 changed files with 74 additions and 45 deletions

View File

@@ -1,7 +1,8 @@
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
name: is-equal
name: is-not-equal
namespace: tekton-pipeline-1
spec:
params:
- name: left
@@ -14,8 +15,8 @@ spec:
#!/bin/sh
if [ $(params.left) = $(params.right) ]; then
echo "$(params.left) == $(params.right)"
exit 0
exit 1
else
echo "$(params.left) != $(params.right)"
exit 1
exit 0
fi

View File

@@ -3,6 +3,7 @@ apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: stage-application-pipeline
namespace: tekton-pipeline-1
spec:
params:
- name: git-repo-name
@@ -22,19 +23,19 @@ spec:
workspace: workspace
params:
- name: url
value: $(inputs.params.git-url)
value: $(params.git-url)
- name: revision
value: $(inputs.params.branch)
value: $(params.branch)
- name: build-and-push
taskRef:
name: build-and-push
conditions:
- conditionRef: "file-exists"
- conditionRef: "is-not-equal"
params:
- name: "left"
value: "stage-infra"
- name: "right"
value: "$(inputs.params.git-repo-name)"
value: "$(params.git-repo-name)"
runAfter:
- clone
workspaces:
@@ -44,9 +45,9 @@ spec:
- name: context
value: "src"
- name: image-name
value: "$(inputs.params.git-repo-name)"
value: "$(params.git-repo-name)"
- name: version
value: "$(inputs.params.branch)"
value: "$(params.branch)"
- name: deploy-app
taskRef:
name: deploy-app

View File

@@ -0,0 +1,5 @@
apiVersion: v1
kind: Namespace
metadata:
name: tekton-pipeline-1

View File

@@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: github-secret
namespace: tekton-pipeline-1
stringData:
token: SECRETSTRING
secret: random-string-data

View File

@@ -4,6 +4,7 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: workspace
namespace: tekton-pipeline-1
spec:
accessModes:
- ReadWriteOnce

View File

@@ -2,15 +2,19 @@ apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: application-pipeline-run
namespace: tekton-pipeline-istio-project-1
namespace: tekton-pipeline-1
spec:
serviceAccountName: service-acc
pipelineRef:
name: application-pipeline
resources:
- name: git-master
resourceRef:
name: git-master
- name: git-experimental
resourceRef:
name: git-experimental
name: stage-application-pipeline
workspaces:
- name: workspace
persistentVolumeClaim:
claimName: workspace
params:
- name: git-repo-name
value: "stage-backend"
- name: git-url
value: "https://github.com/beppevanrolleghem/stage-backend"
- name: branch
value: "master"

View File

@@ -4,6 +4,7 @@ apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: create-repo-webhook-backend
namespace: tekton-pipeline-1
spec:
taskRef:
name: create-webhook
@@ -16,12 +17,12 @@ spec:
- name: GitHubRepo
value: "stage-backend"
- name: GitHubSecretName
value: webhook-secret
value: github-secret
- name: GitHubAccessTokenKey
value: token
- name: GitHubSecretStringKey
value: secret
- name: ExternalDomain
value: "104.155.67.175:8080"
value: "35.189.243.0:8080"
timeout: 1000s
serviceAccountName: service-acc

View File

@@ -4,6 +4,7 @@ apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: create-repo-webhook-frontend
namespace: tekton-pipeline-1
spec:
taskRef:
name: create-webhook
@@ -16,12 +17,12 @@ spec:
- name: GitHubRepo
value: "stage-frontend"
- name: GitHubSecretName
value: webhook-secret
value: github-secret
- name: GitHubAccessTokenKey
value: token
- name: GitHubSecretStringKey
value: secret
- name: ExternalDomain
value: "104.155.67.175:8080"
value: "35.189.243.0:8080"
timeout: 1000s
serviceAccountName: service-acc

View File

@@ -4,6 +4,7 @@ apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: create-repo-webhook-infra
namespace: tekton-pipeline-1
spec:
taskRef:
name: create-webhook
@@ -16,12 +17,12 @@ spec:
- name: GitHubRepo
value: "stage-infra"
- name: GitHubSecretName
value: webhook-secret
value: github-secret
- name: GitHubAccessTokenKey
value: token
- name: GitHubSecretStringKey
value: secret
- name: ExternalDomain
value: "104.155.67.175:8080"
value: "35.189.243.0:8080"
timeout: 1000s
serviceAccountName: service-acc

View File

@@ -4,6 +4,7 @@ apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: create-repo-webhook-mirror
namespace: tekton-pipeline-1
spec:
taskRef:
name: create-webhook
@@ -16,12 +17,12 @@ spec:
- name: GitHubRepo
value: "stage-mirror-service"
- name: GitHubSecretName
value: webhook-secret
value: github-secret
- name: GitHubAccessTokenKey
value: token
- name: GitHubSecretStringKey
value: secret
- name: ExternalDomain
value: "104.155.67.175:8080"
value: "35.189.243.0:8080"
timeout: 1000s
serviceAccountName: service-acc

View File

@@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: allow-creation-binding
namespace: tekton-pipeline-1
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
@@ -10,4 +11,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: service-acc
namespace: default
namespace: tekton-pipeline-1

View File

@@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: allow-creation
namespace: tekton-pipeline-1
rules:
- apiGroups:
- ""

View File

@@ -3,5 +3,6 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: service-acc
namespace: tekton-pipeline-1
secrets:
- name: regcred #docker registry credentials

View File

@@ -3,6 +3,7 @@ apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: build-and-push
namespace: tekton-pipeline-1
spec:
params:
- name: context

View File

@@ -3,6 +3,7 @@ apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: create-webhook
namespace: tekton-pipeline-1
spec:
volumes:
- name: github-secret
@@ -44,7 +45,7 @@ spec:
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\": \"0\" ,\"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
curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)\",\"content_type\": \"json\"}}" -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

View File

@@ -4,6 +4,7 @@ apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: deploy-app
namespace: tekton-pipeline-1
spec:
params:
- name: yaml-location

View File

@@ -3,6 +3,7 @@ apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: git-clone
namespace: tekton-pipeline-1
spec:
workspaces:
- name: output
@@ -50,17 +51,17 @@ spec:
rm -rf "$CHECKOUT_DIR"/..?*
fi
}
if [[ "$(inputs.params.deleteExisting)" == "true" ]] ; then
if [[ "$(params.deleteExisting)" == "true" ]] ; then
cleandir
ls -lah "$CHECKOUT_DIR"
fi
/ko-app/git-init \
-url "$(inputs.params.url)" \
-revision "$(inputs.params.revision)" \
-url "$(params.url)" \
-revision "$(params.revision)" \
-path "$CHECKOUT_DIR" \
-sslVerify "$(inputs.params.sslVerify)" \
-submodules "$(inputs.params.submodules)" \
-depth "$(inputs.params.depth)"
-sslVerify "$(params.sslVerify)" \
-submodules "$(params.submodules)" \
-depth "$(params.depth)"
cd "$CHECKOUT_DIR"
RESULT_SHA="$(git rev-parse HEAD | tr -d '\n')"
EXIT_CODE="$?"

View File

@@ -4,10 +4,16 @@ apiVersion: tekton.dev/v1alpha1
kind: EventListener
metadata:
name: github-event-listener
namespace: tekton-pipeline-1
spec:
serviceAccountName: service-acc
triggers:
- name: github
interceptors:
- github:
eventTypes:
- pull_request
- push
bindings:
- name: github-trigger-binding
template:
@@ -17,6 +23,7 @@ apiVersion: v1
kind: Service
metadata:
name: manual-service
namespace: tekton-pipeline-1
spec:
ports:
- name: http-listener

View File

@@ -3,13 +3,12 @@ apiVersion: tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: github-trigger-binding
namespace: tekton-pipeline-1
spec:
params:
- name: gitrevision
value: $(body.repository.default_branch)
value: "$(body.head_commit.id)"
- name: gitrepositoryurl
value: $(body.repository.clone_url)
value: "$(body.repository.clone_url)"
- name: gitreponame
value: $(body.repository.name)
- name: pipelinename
value: "pipeline for commit $(body.)"
value: $(body.repository.name)

View File

@@ -3,6 +3,7 @@ apiVersion: tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
name: github-trigger-template
namespace: tekton-pipeline-1
spec:
params:
- name: gitrevision
@@ -12,13 +13,11 @@ spec:
description: The git repository url
- name: gitreponame
description: the name of the git repository
- name: pipelinename
description: name the pipelinerun will have
resourcetemplates:
- apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: $(inputs.params.pipelinename)
generateName: github-pipeline-run-
spec:
serviceAccountName: service-acc
pipelineRef:
@@ -29,8 +28,8 @@ spec:
claimName: workspace
params:
- name: git-url
value: $(inputs.params.gitrepositoryurl)
value: $(params.gitrepositoryurl)
- name: branch
value: $(inputs.params.gitrevision)
value: $(params.gitrevision)
- name: git-repo-name
value: $(inputs.params.gitreponame)
value: $(params.gitreponame)