question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Credentials indentation problem during jenkins.yaml importation

See original GitHub issue

Environment

  • Jenkins version 2.176.1
  • Plugin version: 1.21
  • OS : VM Windows Server 2019 Standard - 64 bit

Description

I’m writing my first Jenkins CasC configuration file. When I try to apply it, I’ve got the following error message and I don’t understand how to resolve it :

Item isn't a Sequence

io.jenkins.plugins.casc.ConfiguratorException: Item isn't a Sequence

	at io.jenkins.plugins.casc.model.CNode.asSequence(CNode.java:22)

	at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:342)

	at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:288)

	at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:353)

	at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:288)

	at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$6(ConfigurationAsCode.java:672)

	at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:634)

Caused: io.jenkins.plugins.casc.ConfiguratorException: credentials: error configuring 'credentials' with class com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator configurator

jenkins.yaml credential part

I put directly the passwords value as strings

# Credentials used by Jenkins and by jenkins projects       
credentials:
  system:
    domainCredentials:
      credentials:
        - usernamePassword:
          scope: GLOBAL
          id: "username1"
          username: 'username1'
          password: "password1"
          description: "RD"
        - usernamePassword:
          scope: GLOBAL
          id: "username2"
          username: 'username2'
          password: "password2"
          description:
        - usernamePassword:
          scope: GLOBAL
          id: "username3"
          username: 'username3'
          password: "password3"
          description: "gitlab RD user"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jetersencommented, Jun 27, 2019

Credentials are a bit funky on indenting it has to be 4 space indented after - credentials:

credentials:
  system:
    domainCredentials:
      # global credentials
      - credentials: 
      # must be 4 spaced after this point
          - usernamePassword:
              scope: GLOBAL
              id: artifactory
              username: "${ARTIFACTORY_USERNAME}"
              password: "${ARTIFACTORY_PASSWORD}"
          - usernamePassword:
              scope: GLOBAL
              id: vsphere
              username: "${VSPHERE_USERNAME}"
              password: "${VSPHERE_PASSWORD}"
          - usernamePassword:
              scope: GLOBAL
              id: jenkins_devops
              username: "${JENKINS_DEVOPS_USERNAME}"
              password: "${JENKINS_DEVOPS_APITOKEN}"
              description: Automated administrative tasks in Jenkins
          - basicSSHUserPrivateKey:
              scope: GLOBAL
              id: gitlab_ssh_key
              username: git
              description: SSH key for GitLab
              privateKeySource:
                directEntry:
                  privateKey: "${SSH_PRIVATE_KEY}"
          - GitLabApiTokenImpl:
              scope: GLOBAL
              id: gitlab_token
              apiToken: "${GITLAB_TOKEN}"
              description: Gitlab Token
          - string:
              scope: GLOBAL
              id: slack-token
              secret: "${SLACK_TOKEN}"
              description: Slack token
          - usernamePassword:
              scope: GLOBAL
              id: "gitlabrunner"
              description: "gitlab runner"
              username: "gitlab-runner"
              password: "${GITLABRUNNER_PASSWORD}"
          - vaultAppRoleCredential:
              scope: GLOBAL
              id: "jenkins-build-approle-secret"
              description: "jenkins-build-approle-secret"
              roleId: "${BUILD_APPROLE_ID}"
              secretId: "${BUILD_APPROLE_SECRET_ID}"
0reactions
BlackJam44commented, Jun 27, 2019

Perfect, issue solved ! I wrote it with 4 spaced tab just as you did. I’ve got now a security error but it should be another topic subject

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring a Jenkins Pipeline using a YAML file
We needed to build a new CI that could, at least, address the following: Projects must be built using Docker.
Read more >
Create and Configure Jobs and Pipelines Using YAML
It must be indented to the same level as the parent field. To indent, always use spaces, not tabs. Make sure that number...
Read more >
The `.gitlab-ci.yml` file - GitLab Docs
yml in the root of your repository, which contains the CI/CD configuration. In the .gitlab-ci.yml file, you can define: The scripts you want...
Read more >
jenkinsci/configuration-as-code-plugin - Gitter
package io.jenkins.plugins.casc.impl.secrets; import edu.umd.cs.findbugs.annotations. ... Is your indentation set properly? yaml is very querky about that.
Read more >
29. Troubleshooting Tower - Ansible Documentation
Nginx web server errors are logged in the httpd error log. ... Is your YAML file correctly indented? ... Indentation level is significant...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found