diff --git a/Tekton/conditions/is-equal.yaml b/Tekton/conditions/is-equal.yaml index 92d4ef2..7566b74 100644 --- a/Tekton/conditions/is-equal.yaml +++ b/Tekton/conditions/is-equal.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/pipeline/pipeline.yaml b/Tekton/pipeline/pipeline.yaml index 52c91f4..8770388 100644 --- a/Tekton/pipeline/pipeline.yaml +++ b/Tekton/pipeline/pipeline.yaml @@ -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 diff --git a/Tekton/resources/namespace.yaml b/Tekton/resources/namespace.yaml new file mode 100644 index 0000000..2555370 --- /dev/null +++ b/Tekton/resources/namespace.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: tekton-pipeline-1 + \ No newline at end of file diff --git a/Tekton/resources/secrets.yaml b/Tekton/resources/secrets.yaml index e7824d2..c88eaf0 100644 --- a/Tekton/resources/secrets.yaml +++ b/Tekton/resources/secrets.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: github-secret + namespace: tekton-pipeline-1 stringData: token: SECRETSTRING secret: random-string-data diff --git a/Tekton/resources/workspace.yaml b/Tekton/resources/workspace.yaml index fe2248e..5e7ebeb 100644 --- a/Tekton/resources/workspace.yaml +++ b/Tekton/resources/workspace.yaml @@ -4,6 +4,7 @@ kind: PersistentVolumeClaim apiVersion: v1 metadata: name: workspace + namespace: tekton-pipeline-1 spec: accessModes: - ReadWriteOnce diff --git a/Tekton/runs/pipeline/pipelineRun.yaml b/Tekton/runs/pipeline/pipelineRun.yaml index 1794ace..9df6176 100644 --- a/Tekton/runs/pipeline/pipelineRun.yaml +++ b/Tekton/runs/pipeline/pipelineRun.yaml @@ -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" diff --git a/Tekton/runs/task/webhook-backend.yaml b/Tekton/runs/task/webhook-backend.yaml index 36fc88a..a84d85d 100644 --- a/Tekton/runs/task/webhook-backend.yaml +++ b/Tekton/runs/task/webhook-backend.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/runs/task/webhook-frontend.yaml b/Tekton/runs/task/webhook-frontend.yaml index 8e10e43..dd6cd82 100644 --- a/Tekton/runs/task/webhook-frontend.yaml +++ b/Tekton/runs/task/webhook-frontend.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/runs/task/webhook-infra.yaml b/Tekton/runs/task/webhook-infra.yaml index ecf09a4..5f1def3 100644 --- a/Tekton/runs/task/webhook-infra.yaml +++ b/Tekton/runs/task/webhook-infra.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/runs/task/webhook-mirror.yaml b/Tekton/runs/task/webhook-mirror.yaml index 5d5d784..f35666c 100644 --- a/Tekton/runs/task/webhook-mirror.yaml +++ b/Tekton/runs/task/webhook-mirror.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/service-accounts/cluster-role-binding.yaml b/Tekton/service-accounts/cluster-role-binding.yaml index 392c0b7..6b0e8d6 100644 --- a/Tekton/service-accounts/cluster-role-binding.yaml +++ b/Tekton/service-accounts/cluster-role-binding.yaml @@ -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 \ No newline at end of file + namespace: tekton-pipeline-1 \ No newline at end of file diff --git a/Tekton/service-accounts/cluster-role.yaml b/Tekton/service-accounts/cluster-role.yaml index 8d712c5..cf1f860 100644 --- a/Tekton/service-accounts/cluster-role.yaml +++ b/Tekton/service-accounts/cluster-role.yaml @@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: allow-creation + namespace: tekton-pipeline-1 rules: - apiGroups: - "" diff --git a/Tekton/service-accounts/service-account.yaml b/Tekton/service-accounts/service-account.yaml index e2396f8..6f002a8 100644 --- a/Tekton/service-accounts/service-account.yaml +++ b/Tekton/service-accounts/service-account.yaml @@ -3,5 +3,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: service-acc + namespace: tekton-pipeline-1 secrets: - name: regcred #docker registry credentials \ No newline at end of file diff --git a/Tekton/tasks/build-and-push.yaml b/Tekton/tasks/build-and-push.yaml index 3e9ac51..5d701a5 100644 --- a/Tekton/tasks/build-and-push.yaml +++ b/Tekton/tasks/build-and-push.yaml @@ -3,6 +3,7 @@ apiVersion: tekton.dev/v1alpha1 kind: Task metadata: name: build-and-push + namespace: tekton-pipeline-1 spec: params: - name: context diff --git a/Tekton/tasks/create-webhook.yaml b/Tekton/tasks/create-webhook.yaml index 9e46030..ddef1d8 100644 --- a/Tekton/tasks/create-webhook.yaml +++ b/Tekton/tasks/create-webhook.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/tasks/deploy-app.yaml b/Tekton/tasks/deploy-app.yaml index 8b9604b..5a1cc1d 100644 --- a/Tekton/tasks/deploy-app.yaml +++ b/Tekton/tasks/deploy-app.yaml @@ -4,6 +4,7 @@ apiVersion: tekton.dev/v1alpha1 kind: Task metadata: name: deploy-app + namespace: tekton-pipeline-1 spec: params: - name: yaml-location diff --git a/Tekton/tasks/git-clone.yaml b/Tekton/tasks/git-clone.yaml index b38e1dd..cf74026 100644 --- a/Tekton/tasks/git-clone.yaml +++ b/Tekton/tasks/git-clone.yaml @@ -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="$?" diff --git a/Tekton/triggers/event-listener.yaml b/Tekton/triggers/event-listener.yaml index 2d80256..a437af9 100644 --- a/Tekton/triggers/event-listener.yaml +++ b/Tekton/triggers/event-listener.yaml @@ -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 diff --git a/Tekton/triggers/trigger-binding.yaml b/Tekton/triggers/trigger-binding.yaml index 9391766..5ffc9f8 100644 --- a/Tekton/triggers/trigger-binding.yaml +++ b/Tekton/triggers/trigger-binding.yaml @@ -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.)" \ No newline at end of file + value: $(body.repository.name) \ No newline at end of file diff --git a/Tekton/triggers/trigger-template.yaml b/Tekton/triggers/trigger-template.yaml index 97156c3..5737299 100644 --- a/Tekton/triggers/trigger-template.yaml +++ b/Tekton/triggers/trigger-template.yaml @@ -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) \ No newline at end of file + value: $(params.gitreponame) \ No newline at end of file