From 5651b72dcab638fc395409d4f7060389aa1791e5 Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Wed, 27 Nov 2024 11:46:59 +0200 Subject: [PATCH] changes in CI configuration to make tekton pipeline work --- scaffolder-templates/build/.gitlab-ci.yml | 16 +++++++++------- .../build/argocd/pipelinerun.template | 3 ++- .../gitlab-workflow/template.yaml | 2 +- scaffolder-templates/gitops/bootstrap/README.md | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scaffolder-templates/build/.gitlab-ci.yml b/scaffolder-templates/build/.gitlab-ci.yml index e3daa27..4c45650 100644 --- a/scaffolder-templates/build/.gitlab-ci.yml +++ b/scaffolder-templates/build/.gitlab-ci.yml @@ -1,6 +1,15 @@ stages: + - wait - update +wait_for_value: + tags: + - shared-podman + stage: wait + image: ubuntu:latest + script: | + sleep 5 + update_pipelinerun: tags: - shared-podman # Change to whatever tag your Gitlab runner is set to @@ -14,15 +23,8 @@ update_pipelinerun: COMMIT_ID=$(git rev-parse --short HEAD) git config --global user.email "$COMMIT_AUTHOR_EMAIL" git config --global user.name "$COMMIT_AUTHOR_NAME" - - while [ -z "$PROJECT_ACCESS_TOKEN" ]; do - echo "Waiting for PROJECT_ACCESS_TOKEN to be set..." - sleep 10 - done echo "PROJECT_ACCESS_TOKEN is set to: $PROJECT_ACCESS_TOKEN" - git remote set-url origin https://token:$PROJECT_ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git - cd argocd sed "s/__COMMIT_ID__/$COMMIT_ID/g" pipelinerun.template > pipelinerun.yaml git add pipelinerun.yaml diff --git a/scaffolder-templates/build/argocd/pipelinerun.template b/scaffolder-templates/build/argocd/pipelinerun.template index 17bb48c..9798d5b 100644 --- a/scaffolder-templates/build/argocd/pipelinerun.template +++ b/scaffolder-templates/build/argocd/pipelinerun.template @@ -45,4 +45,5 @@ spec: secretName: docker-credentials - name: ssh-creds secret: - secretName: git-ssh-credentials \ No newline at end of file + secretName: | + $( values.gitOpsUrl | contains("gitlab") ? gitlab-ssh-credentials : git-ssh-credentials) \ No newline at end of file diff --git a/scaffolder-templates/gitlab-workflow/template.yaml b/scaffolder-templates/gitlab-workflow/template.yaml index f94743c..949fc3d 100644 --- a/scaffolder-templates/gitlab-workflow/template.yaml +++ b/scaffolder-templates/gitlab-workflow/template.yaml @@ -392,7 +392,7 @@ spec: system: ${{ parameters.system }} applicationType: workflow-project description: ${{ parameters.description }} - sourceControl: gitlab.com # CHECK if not cee redhat + sourceControl: gitlab.com lifecycle: development gitUrl: git@${{ parameters.gitlabHost }}:${{ parameters.orgName }}/${{ parameters.repoName }}.git gitOpsUrl: git@${{ parameters.gitlabHost }}:${{ parameters.orgName }}/${{ parameters.repoName }}-gitops.git diff --git a/scaffolder-templates/gitops/bootstrap/README.md b/scaffolder-templates/gitops/bootstrap/README.md index 65c0e19..6f14934 100644 --- a/scaffolder-templates/gitops/bootstrap/README.md +++ b/scaffolder-templates/gitops/bootstrap/README.md @@ -7,11 +7,12 @@ Before applying the manifests, there is a need to replace the `__REPLACE_SSH_PRI Either manually edit the file or login to the target cluster and run the following command: ``` -git clone https://github.com/${{ values.orgName }}/${{ values.repoName }}.git +# Change the Gitlab host to the one you are using, for example, gitlab.cee.redhat.com, gitlab.com, etc. +git clone https://gitlab.cee.redhat.com/${{ values.orgName }}/${{ values.repoName }}.git cd ${{ values.repoName }}/bootstrap # Optionally, if edited the file manually -SSH_PRIVATE_KEY=$(oc get secrets -n orchestrator-gitops git-ssh-credentials -o jsonpath='{.data.id_rsa}') +SSH_PRIVATE_KEY=$(oc get secrets -n orchestrator-gitops gitlab-ssh-credentials -o jsonpath='{.data.id_rsa}') sed -i "s/__REPLACE_SSH_PRIVATE_KEY__/$SSH_PRIVATE_KEY/" ${{values.workflowId}}-argocd-repo.yaml kubectl apply -f . @@ -20,7 +21,7 @@ kubectl apply -f . **Note:** If you're not logged into the repository, you need to provide a personal access token (PAT) as part of the clone URL. ``` -git clone https://@github.com/${{ values.orgName }}/${{ values.repoName }}.git +git clone https://@gitlab.cee.redhat.com/${{ values.orgName }}/${{ values.repoName }}.git ``` Replace `` with your personal access token. Ensure the token has the necessary permissions to access the repository.