items.yaml
The items.yaml
file contains a list of items to create or update within the instance.
-
By default, items that are present on the instance in the UI but not included in the
items.yaml
file will remain. However, you can change this behavior using differentRemoveStrategy
options. -
You must install the prerequisite CloudBees CI software and plugins based on the item type you are creating.
-
If you want to customize your
items.yaml
file using environment variables or using thevariables.yaml
file in your bundle, you must install the Jenkins Configuration-as-Code plugin.
Refer to Create items with CasC for controllers and Create items with CasC for the operations center for specific information on creating items for a controller or an operations center.
Property | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
removeStrategy |
object |
Optional. It specifies the strategy to be followed when you apply a new configuration to an existing instance.
Valid values are:
|
||||||||||||||||||||
root (Only for controller CasC bundles) |
string |
Optional. Defines the root path for item creation. The path must already exist on the controller instance for the items to be successfully created. For more information, refer to Configuring bundle inheritance with CasC. |
||||||||||||||||||||
items |
list of objects |
Required. The list of items. |
||||||||||||||||||||
kind |
string |
Required. It defines the kind of item created. Supported items:
|
||||||||||||||||||||
name |
string |
Required. The name of the item. |
||||||||||||||||||||
displayName |
string |
Optional. The display name of the item. |
||||||||||||||||||||
description |
string |
Optional. The description of the item. |
||||||||||||||||||||
groups |
list of objects |
Optional. The list of RBAC groups included in the item. |
||||||||||||||||||||
name |
string |
Required. The name of the group. |
||||||||||||||||||||
members |
object |
Required. |
||||||||||||||||||||
users |
list of strings |
Optional. A list of user ids of users that belong to the group. |
||||||||||||||||||||
roles |
list |
Required. A list of RBAC roles that are assigned to this group. |
||||||||||||||||||||
name |
string |
Required. The name of the assigned role. |
||||||||||||||||||||
filteredRoles |
list of strings |
Optional. The list of roles to filter. |
Example items.yaml file
items.yaml for a controller
If a CloudBees CI GitHub Organization is used to configure a repository from a GitHub Enterprise server and you add the server to the Configure System screen, API endpoint is a required field. You must verify that the apiUri property is configured in the items.yaml file. If the GitHub server is not an enterprise server, you can optionally remove the apiUri property from the items.yaml file.
|
removeStrategy: items: "none" rbac: "sync" items: - kind: "folder" name: project-${team_group} displayName: "Project Alpha" description: "Project Alpha is going to change the world!" properties: - folderCredentialsProperty: folderCredentials: - credentials: - usernamePassword: password: ${secret_location} scope: GLOBAL description: description id: test-id usernameSecret: false username: test-user domain: {} groups: - name: "Project Alpha Developers" members: external_groups: - ldap-project-${team_group} roles: - name: "developer" items:(1) - kind: "folder" name: "project-alpha-tests" displayName: "Project Alpha Tests" items: - kind: "folder" name: "test-1" - kind: "folder" name: "test-2" - kind: "folder" name: "project-beta" displayName: "Project Beta" description: "Secret project! Only Admins can see this!" filteredRoles:(2) - "developer" - "browser"
1 | Items can be nested within other items, enabling users to create a folder structure. |
2 | Roles can be filtered, for example to allow only administrators to view certain projects. |
removeStrategy: items: "none" rbac: "sync" items:(1) - kind: "folder" name: project-${team_group} displayName: "Project Alpha" description: "Project Alpha is going to change the world!" groups: - name: "Project Alpha Developers" members: external_groups: - ldap-project-${team_group} roles: - name: "developer" items: - kind: "folder" name: "project-alpha-tests" displayName: "Project Alpha Tests" items: - kind: "folder" name: "test-1" - kind: "folder" name: "test-2" properties: - envVars: vars: FOO: "BAR" BAR: "BAZ" - folderLibraries: libraries: - libraryConfiguration: implicit: false allowVersionOverride: true retriever: modernSCM: scm: github: traits: - gitHubBranchDiscovery: strategyId: 1 - gitHubPullRequestDiscovery: strategyId: 1 - gitHubForkDiscovery: trust: gitHubTrustEveryone: {} strategyId: 1 repoOwner: "company" id: "library-id" repository: "project-alpha" configuredByUrl: true repositoryUrl: "https://github.com/company/project-alpha" name: "my-library" includeInChangesets: true - folderCredentialsProperty: folderCredentials: - credentials: - usernamePassword: password: ${secret_location} scope: GLOBAL description: description id: test-id usernameSecret: false username: test-user domain: {} - itemRestrictions: allowedTypes: - "org.jenkinsci.plugins.workflow.job.WorkflowJob" - "hudson.matrix.MatrixProject" - "hudson.model.FreeStyleProject" - "com.cloudbees.hudson.plugins.modeling.impl.jobTemplate.JobTemplate" - "com.cloudbees.hudson.plugins.folder.Folder" - "com.cloudbees.hudson.plugins.modeling.impl.builder.BuilderTemplate" - "com.cloudbees.hudson.plugins.modeling.impl.auxiliary.AuxModel" - "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" - "com.cloudbees.hudson.plugins.modeling.impl.publisher.PublisherTemplate" - "com.cloudbees.hudson.plugins.modeling.impl.folder.FolderTemplate" - "com.infradna.hudson.plugins.backup.BackupProject" filter: true items: - kind: "freeStyle" name: "project-alpha-freestyle" displayName: "Freestyle job in the Project Alpha folder" - kind: "folder" name: "project-beta" displayName: "Project Beta" description: "Secret project! Only Admins can see this!" filteredRoles:(2) - "developer" - "browser"
1 | Items can be nested within other items, enabling users to create a folder structure. |
2 | Roles can be filtered, for example to allow only administrators to view certain projects. |
removeStrategy: items: "none" rbac: "sync" items: - kind: "freeStyle" name: "project-alpha-freestyle" displayName: "Project Alpha Freestyle" description: "This is Project Alpha's Freestyle job!" disabled: false scm: gitSCM: extensions: - checkoutOption: timeout: 4 gitTool: git userRemoteConfigs: - userRemoteConfig: name: "developer-a" credentialsId: "credentials-id" url: "git@github.com:company/project-alpha.git" browser: githubWeb: repoUrl: "https://github.com/company/project-alpha" doGenerateSubmoduleConfigurations: false branches: - branchSpec: name: "*/main" buildDiscarder: logRotator: artifactDaysToKeep: 3 daysToKeep: 1 numToKeep: 2 artifactNumToKeep: 4 scmCheckoutStrategy: standard: { } builders: - shell: command: "pwd"
removeStrategy: items: "none" rbac: "sync" items: - kind: "pipeline" name: "project-beta-pipeline-job" displayName: "Project Beta Pipeline job" description: "This is Project Beta's Pipeline job!" definition: cpsScmFlowDefinition: scriptPath: "Jenkinsfile" scm: gitSCM: gitTool: "git" userRemoteConfigs: - userRemoteConfig: name: "developer-b" credentialsId: "credentials-id" url: "git@github.com:company/project-beta.git" extensions: - checkoutOption: timeout: 2 - cloneOption: reference: "/workspace/git" noTags: false honorRefspec: false shallow: true timeout: 5 branches: - branchSpec: name: "*/main"
removeStrategy: items: "none" rbac: "sync" items: - kind: "multibranch" name: "project-beta-multibranch-pipeline" displayName: "Project Beta Multibranch Pipeline" description: "This is Project Beta's Multibranch Pipeline job!" orphanedItemStrategy: defaultOrphanedItemStrategy: pruneDeadBranches: true daysToKeep: 3 numToKeep: 4 projectFactory: workflowBranchProjectFactory: scriptPath: "Jenkinsfile" sourcesList: - branchSource: source: github: traits: - gitHubBranchDiscovery: strategyId: 1 - gitHubPullRequestDiscovery: strategyId: 1 - gitHubForkDiscovery: trust: gitHubTrustEveryone: {} strategyId: 1 - headWildcardFilter: excludes: "feature/*" includes: "*" - gitHubSshCheckout: credentialsId: "github-ssh" repoOwner: "company" id: "scm-source-id" repository: "project-alpha" configuredByUrl: true repositoryUrl: "https://github.com/company/project-beta" strategy: allBranchesSame: {}
removeStrategy: items: "none" rbac: "sync" items: - kind: "organizationFolder" name: "project-alpha-github-org" displayName: "Project Alpha GitHub Organization job" description: "This is Project Alpha's Github Organization job!" navigators: - github: traits: - checkoutOptionTrait: extension: checkoutOption: timeout: 5 - cloneOptionTrait: extension: cloneOption: reference: main noTags: false honorRefspec: false shallow: true timeout: 6 repoOwner: "company" projectFactories: - customMultiBranchProjectFactory: factory: customBranchProjectFactory: marker: ".my-marker-file" definition: cpsScmFlowDefinition: scriptPath: "pipelines/default/Jenkinsfile" scm: gitSCM: extensions: - checkoutOption: timeout: 4 gitTool: "git" userRemoteConfigs: - userRemoteConfig: name: "admin-a" credentialsId: "credentials-id" url: "git@github.com:company/project-alpha.git" browser: githubWeb: repoUrl: "git@github.com:company/project-alpha" branches: - branchSpec: name: "*/main" lightweight: false
removeStrategy: items: "none" rbac: "sync" items: - kind: "organizationFolder" name: "project-beta-bitbucket-org" displayName: "Project Beta Bitbucket Organization job" description: "This is Project Beta's Bitbucket Organization job!" navigators: - bitbucket: traits: - bitbucketBranchDiscovery: strategyId: 1 - bitbucketPullRequestDiscovery: strategyId: 1 - bitbucketForkDiscovery: trust: bitbucketTrustTeam: {} strategyId: 1 repoOwner: "company" projectFactories: - workflowMultiBranchProjectFactory: scriptPath: "Jenkinsfile"
removeStrategy: items: "none" rbac: "sync" items: - kind: "cloudbeesTemplatedJob" name: "job-template-alpha" model: "folder1/template"(1) attributes:(2) - value: job-template-alpha(3) key: name - value: the description key: description - value: pwd key: command
1 | The full path to the template. |
2 | Attributes defined in the CloudBees job template. |
3 | The name of the new instance you are creating based on the template. |
removeStrategy: items: "none" rbac: "sync" items: - kind: "cloudbeesTemplatedJob" name: "my-new-job" catalog: "project-alpha-pipeline-template-catalog"(1) model: "template-alpha"(2) attributes:(3) - value: template-alpha(4) key: name - value: the description key: description - value: pwd key: command
1 | The name of the Pipeline Template Catalog that is defined in the catalog.yaml file. |
2 | The name of the template within the Pipeline Template Catalog. |
3 | Attributes defined in the CloudBees job template. |
4 | The name of the new job you are creating based on the template. |
removeStrategy: items: "none" rbac: "sync" items: - kind: backupAndRestore name: project-alpha-backup displayName: "Project Alpha backup" description: "This is Project Alpha's backup job!" buildersList: - backupBuilder: subjects: - buildRecordSubject: excludes: foo - jobConfigurationSubject: excludes: bar - systemConfigurationSubject: excludes: baz omitMasterKey: true format: zipFormat: {} exclusive: false store: s3Store: bucketName: bucket sse: true bucketFolder: bucketFolder credentialsId: testCredential region: us-east-1 retentionPolicy: exponentialDecayRetentionPolicy: {} safeDelaySeconds: 42 label: agent-for-backup triggers: - cron: spec: 0 0 * * * buildDiscarder: logRotator: numToKeep: 5
removeStrategy: items: "none" rbac: "sync" items: - kind: backupAndRestore name: project-alpha-restore displayName: "Project Alpha restore" description: "This is Project Alpha's restore job!" buildersList: - restoreBuilder: ignoreConfirmationFile: false preserveJenkinsHome: true ignoreDigestCheck: true store: s3Store: bucketName: bucket sse: true bucketFolder: bucketFolder credentialsId: testCredential region: us-east-1 restoreDirectory: /tmp label: agent-for-restore buildDiscarder: logRotator: numToKeep: 5
items.yaml for an operations center
|
removeStrategy: items: "none" rbac: "sync" items: - kind: "folder" name: project-${team_group} displayName: "Project Alpha" description: "Project Alpha is going to change the world!" properties: - folderCredentialsProperty: folderCredentials: - credentials: - usernamePassword: password: ${secret_location} scope: GLOBAL description: description id: test-id usernameSecret: false username: test-user domain: {} groups: - name: "Project Alpha Developers" members: external_groups: - ldap-project-${team_group} roles: - name: "developer" items:(1) - kind: "folder" name: "project-alpha-tests" displayName: "Project Alpha Tests" items: - kind: "folder" name: "test-1" - kind: "folder" name: "test-2" - kind: "folder" name: "project-beta" displayName: "Project Beta" description: "Secret project! Only Admins can see this!" filteredRoles:(2) - "developer" - "browser"
1 | Items can be nested within other items, enabling users to create a folder structure. |
2 | Roles can be filtered, for example to allow only administrators to view certain projects. |
removeStrategy: items: "none" rbac: "sync" items:(1) - kind: "folder" name: project-${team_group} displayName: "Project Alpha" description: "Project Alpha is going to change the world!" groups: - name: "Project Alpha Developers" members: external_groups: - ldap-project-${team_group} roles: - name: "developer" items: - kind: "folder" name: "project-alpha-tests" displayName: "Project Alpha Tests" items: - kind: "folder" name: "test-1" - kind: "folder" name: "test-2" properties: - envVars: vars: FOO: "BAR" BAR: "BAZ" - folderLibraries: libraries: - libraryConfiguration: implicit: false allowVersionOverride: true retriever: modernSCM: scm: github: traits: - gitHubBranchDiscovery: strategyId: 1 - gitHubPullRequestDiscovery: strategyId: 1 - gitHubForkDiscovery: trust: gitHubTrustEveryone: {} strategyId: 1 repoOwner: "company" id: "library-id" repository: "project-alpha" configuredByUrl: true repositoryUrl: "https://github.com/company/project-alpha" name: "my-library" includeInChangesets: true - folderCredentialsProperty: folderCredentials: - credentials: - usernamePassword: password: ${secret_location} scope: GLOBAL description: description id: test-id usernameSecret: false username: test-user domain: {} - itemRestrictions: allowedTypes: - "org.jenkinsci.plugins.workflow.job.WorkflowJob" - "hudson.matrix.MatrixProject" - "hudson.model.FreeStyleProject" - "com.cloudbees.hudson.plugins.modeling.impl.jobTemplate.JobTemplate" - "com.cloudbees.hudson.plugins.folder.Folder" - "com.cloudbees.hudson.plugins.modeling.impl.builder.BuilderTemplate" - "com.cloudbees.hudson.plugins.modeling.impl.auxiliary.AuxModel" - "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" - "com.cloudbees.hudson.plugins.modeling.impl.publisher.PublisherTemplate" - "com.cloudbees.hudson.plugins.modeling.impl.folder.FolderTemplate" - "com.infradna.hudson.plugins.backup.BackupProject" filter: true items: - kind: "freeStyle" name: "project-alpha-freestyle" displayName: "Freestyle job in the Project Alpha folder" - kind: "folder" name: "project-beta" displayName: "Project Beta" description: "Secret project! Only Admins can see this!" filteredRoles:(2) - "developer" - "browser"
1 | Items can be nested within other items, enabling users to create a folder structure. |
2 | Roles can be filtered, for example to allow only administrators to view certain projects. |
removeStrategy: items: "none" rbac: "sync" items: - kind: "freeStyle" name: "project-alpha-freestyle" displayName: "Project Alpha Freestyle" description: "This is Project Alpha's Freestyle job!" disabled: false scm: gitSCM: extensions: - checkoutOption: timeout: 4 gitTool: git userRemoteConfigs: - userRemoteConfig: name: "developer-a" credentialsId: "credentials-id" url: "git@github.com:company/project-alpha.git" browser: githubWeb: repoUrl: "https://github.com/company/project-alpha" doGenerateSubmoduleConfigurations: false branches: - branchSpec: name: "*/main" buildDiscarder: logRotator: artifactDaysToKeep: 3 daysToKeep: 1 numToKeep: 2 artifactNumToKeep: 4 scmCheckoutStrategy: standard: { } builders: - shell: command: "pwd"
removeStrategy: items: "none" rbac: "sync" items: - kind: clusterOpProject name: "project-alpha-cluster-operations" displayName: "Project Alpha - Cluster operations" description: "These are Project Alpha's cluster operations!" disabled: false concurrentBuild: true operations: - masterClusterOperation: failureMode: IMMEDIATELY clusterOpSteps: - backupClusterOpStep: subjects: - buildRecordSubject: {} - jobConfigurationSubject: {} format: zipFormat: {} retentionPolicy: exponentialDecayRetentionPolicy: {} safeDelaySeconds: 10 store: s3Store: bucketName: ' mybucket' sse: true bucketFolder: somefolder credentialsId: 'my-aws-credentials-id' region: us-east-1 timeoutSeconds: 0 itemSource: jenkinsRootItemSource: {} filters: - isMasterOnlineFilter: {} inParallel: 0 noRetries: 0
removeStrategy: items: "none" rbac: "sync" items: - kind: managedController displayName: "managed-controller-alpha" name: "managed-controller-alpha" description: "This is Project Alpha's managed controller!" groups: - name: "Project Alpha Developers" members: users: - developer-1 roles: - name: developer properties: - configurationAsCode: bundle: bundle-1 - healthReporting: enabled: false - owner: delay: 5 owners: '' - envelopeExtension: allowExceptions: false - sharedConfigurationOptOut: optOut: false - licensing: strategy: perUserLicensingStrategy: {} configuration: kubernetes: allowExternalAgents: false replication:(1) config: maxReplicas: 5 replicas: 3 targetCPUUtilizationPercentage: 80 terminationGracePeriodSeconds: 1200 #image: cloudbees/mc-foo-image # uncomment to use a non-default image memory: 3072(2) fsGroup: '1000' cpus: 1.0 readinessTimeoutSeconds: 5 livenessInitialDelaySeconds: 300 readinessInitialDelaySeconds: 30 clusterEndpointId: default disk: 50 readinessFailureThreshold: 100 livenessTimeoutSeconds: 10 domain: managed-controller-alpha livenessPeriodSeconds: 10 javaOptions: -DfooSystemProperty="foo" -Dbar="bar" yaml: |- --- apiVersion: apps/v1 kind: StatefulSet metadata: labels: my-label: my-value
1 | Settings for a managed controller with CloudBees High Availability (HA), with 3 replicas, autoscaling enabled allowing up to 5 replicas, and a CPU threshold of 80% to trigger upscaling. maxReplicas and targetCPUUtilizationPercentage are not required if autoscaling is disabled. Then maxReplicas is set to 0 by default. |
2 | Some settings, such as controller memory, require the controller to be reprovisioned for the setting to take effect. If the managed controller is running in High Availability (HA) mode, these changes trigger a rolling restart without reprovisioning. |
removeStrategy: items: "none" rbac: "sync" items: - kind: clientController displayName: "client-controller-beta" name: "client-controller-beta" description: "This is Project Beta's client controller!" groups: - name: "Project Beta Developers" members: users: - developer-1 roles: - name: developer properties: - configurationAsCode: bundle: bundle-2 - healthReporting: enabled: false - owner: delay: 5 owners: '' - envelopeExtension: allowExceptions: false - sharedConfigurationOptOut: optOut: false - licensing: strategy: perUserLicensingStrategy: {} - webSocket: enabled: true
removeStrategy: items: "none" rbac: "sync" items: - kind: "sharedAgent" displayName: "Shared Agent for this cluster" name: "shared-agent-1" description: "Shared Agent for this cluster" remoteFS: "/tmp/remote" properties: - sharedAgent: customizers: - envVars: value: SKIP_RELEASE: "TRUE" JENKINS_VERSION: "2.303" - toolLocation: value: - name: "git" type: "git" home: "/usr/local/git" - name: "maven3" type: "mvn" home: "/usr/local/mvn" labels: "ubuntu" launcher: inboundAgent: webSocket: true workDirSettings: remotingWorkDirSettings: internalDir: "/path/to/directory" disabled: false failIfWorkDirIsMissing: true workDirPath: "/path/to/directory" agentStartupOptions: "-noCertificateCheck" vmargs: "-Xms2G -Xmx2G" tunnel: "192.1.1.45:22" mode: EXCLUSIVE numExecutors: 10 retentionStrategy: sharedNodeRetentionStrategy: {}
removeStrategy: items: "none" rbac: "sync" items: - kind: "sharedCloud" displayName: "Shared Cloud Agent for this cluster" name: "shared-cloud-1" description: "Shared Cloud Agent for this cluster" properties: - sharedCloud: customizers: - envVars: value: SKIP_RELEASE: "TRUE" JENKINS_VERSION: "2.303" - toolLocation: value: - name: "git" type: "git" home: "/usr/local/git" - name: "maven3" type: "mvn" home: "/usr/local/mvn" cloud: inboundAgents: mode: EXCLUSIVE numExecutors: 10 remoteFS: "/path/to/directory" labels: "ubuntu" launcher: inboundAgent: webSocket: true workDirSettings: remotingWorkDirSettings: internalDir: "/path/to/directory" disabled: false failIfWorkDirIsMissing: true workDirPath: "/path/to/directory" agentStartupOptions: "-noCertificateCheck" vmargs: "-Xms2G -Xmx2G" tunnel: "192.1.1.45:22"
removeStrategy: items: "none" rbac: "sync" items: - kind: backupAndRestore name: project-alpha-backup displayName: "Project Alpha backup" description: "This is Project Alpha's backup job!" buildersList: - backupBuilder: subjects: - buildRecordSubject: excludes: foo - jobConfigurationSubject: excludes: bar - systemConfigurationSubject: excludes: baz omitMasterKey: true format: zipFormat: {} exclusive: false store: s3Store: bucketName: bucket sse: true bucketFolder: bucketFolder credentialsId: testCredential region: us-east-1 retentionPolicy: exponentialDecayRetentionPolicy: {} safeDelaySeconds: 42 label: agent-for-backup triggers: - cron: spec: 0 0 * * * buildDiscarder: logRotator: numToKeep: 5