From 41dac85ea1a984b51cf27d7f0c9d7a682f2059ee Mon Sep 17 00:00:00 2001 From: Piotr Ryba <55996264+prryb@users.noreply.github.com> Date: Wed, 5 May 2021 09:27:43 +0200 Subject: [PATCH] #552 Seed Jobs: Don't Validate "external" Credential Type (#556) * Don't validate external credential type The operator shouldn't try to fetch credentials that have their types defined as `external` - that means that credentials are supplied externally, without using k8s secrets. * Docs: Add example of `external` credential type --- pkg/configuration/user/seedjobs/validate.go | 3 +-- .../Getting Started/Preview/configuration.md | 21 +++++++++++++++++++ .../Getting Started/latest/configuration.md | 21 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/pkg/configuration/user/seedjobs/validate.go b/pkg/configuration/user/seedjobs/validate.go index 7944cd6d..5e656bd3 100644 --- a/pkg/configuration/user/seedjobs/validate.go +++ b/pkg/configuration/user/seedjobs/validate.go @@ -55,8 +55,7 @@ func (s *seedJobs) ValidateSeedJobs(jenkins v1alpha2.Jenkins) ([]string, error) } if seedJob.JenkinsCredentialType == v1alpha2.BasicSSHCredentialType || - seedJob.JenkinsCredentialType == v1alpha2.UsernamePasswordCredentialType || - seedJob.JenkinsCredentialType == v1alpha2.ExternalCredentialType { + seedJob.JenkinsCredentialType == v1alpha2.UsernamePasswordCredentialType { secret := &v1.Secret{} namespaceName := types.NamespacedName{Namespace: jenkins.Namespace, Name: seedJob.CredentialID} err := s.Client.Get(context.TODO(), namespaceName, secret) diff --git a/website/content/en/docs/Getting Started/Preview/configuration.md b/website/content/en/docs/Getting Started/Preview/configuration.md index 19721edd..f3c4b8a7 100644 --- a/website/content/en/docs/Getting Started/Preview/configuration.md +++ b/website/content/en/docs/Getting Started/Preview/configuration.md @@ -221,6 +221,26 @@ stringData: ### External authentication You can use `external` credential type if you want to configure authentication using Configuration As Code or Groovy Script. +Example: +```yaml +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-external + credentialType: external + credentialID: k8s-external + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +``` + +Remember that `credentialID` must match the id of the credentials configured in Jenkins. Consult the +[Jenkins docs for using credentials][jenkins-using-credentials] for details. + ## HTTP Proxy for downloading plugins To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.: @@ -313,3 +333,4 @@ Example config file to modify and use: [job-dsl]:https://github.com/jenkinsci/job-dsl-plugin [kubernetes-credentials-provider]:https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ +[jenkins-using-credentials]:https://www.jenkins.io/doc/book/using/using-credentials/ diff --git a/website/content/en/docs/Getting Started/latest/configuration.md b/website/content/en/docs/Getting Started/latest/configuration.md index fee5aeb9..439a0de8 100644 --- a/website/content/en/docs/Getting Started/latest/configuration.md +++ b/website/content/en/docs/Getting Started/latest/configuration.md @@ -221,6 +221,26 @@ stringData: ### External authentication You can use `external` credential type if you want to configure authentication using Configuration As Code or Groovy Script. +Example: +```yaml +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-external + credentialType: external + credentialID: k8s-external + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +``` + +Remember that `credentialID` must match the id of the credentials configured in Jenkins. Consult the +[Jenkins docs for using credentials][jenkins-using-credentials] for details. + ## HTTP Proxy for downloading plugins To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.: @@ -313,3 +333,4 @@ Example config file to modify and use: [job-dsl]:https://github.com/jenkinsci/job-dsl-plugin [kubernetes-credentials-provider]:https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ +[jenkins-using-credentials]:https://www.jenkins.io/doc/book/using/using-credentials/