🗑️ Codacy markdown issues (#848)

This commit is contained in:
Joseph Petersen 2019-04-20 15:50:58 +02:00 committed by GitHub
parent 0dc1f3fa75
commit 3ef37525f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 326 additions and 356 deletions

2
.github/stale.yml vendored
View File

@ -20,7 +20,7 @@ markComment: >
This issue has been automatically marked as stale because it has not had This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you recent activity. It will be closed if no further activity occurs. Thank you
for your contributions. for your contributions.
pulls: pulls:
markComment: > markComment: >
This pull request has been automatically marked as stale because it has not had This pull request has been automatically marked as stale because it has not had

View File

@ -139,7 +139,6 @@ mvn hpi:run
```text ```text
... ...
...
INFO: Jenkins is fully up and running INFO: Jenkins is fully up and running
``` ```

View File

@ -5,10 +5,7 @@ Alauda DevOps Sync plugin configuration belongs under `unclassified` root elemen
## sample configuration ## sample configuration
```yaml ```yaml
jenkins:
[...]
unclassified: unclassified:
[...]
alaudaSync: alaudaSync:
enabled: true enabled: true
jenkinsService: jenkins jenkinsService: jenkins

View File

@ -5,17 +5,14 @@ Artifactory plugin configuration belongs under `unclassified` root element
## sample configuration ## sample configuration
```yaml ```yaml
jenkins:
[...]
unclassified: unclassified:
[...]
artifactorybuilder: artifactorybuilder:
useCredentialsPlugin: true useCredentialsPlugin: true
artifactoryServers: artifactoryServers:
- serverId: artifactory - serverId: artifactory
artifactoryUrl: http://acme.com/artifactory artifactoryUrl: http://acme.com/artifactory
deployerCredentialsConfig: deployerCredentialsConfig:
credentialsId: 'artifactory' credentialsId: "artifactory"
resolverCredentialsConfig: resolverCredentialsConfig:
username: artifactory_user username: artifactory_user
password: ${ARTIFACTORY_PASSWORD} password: ${ARTIFACTORY_PASSWORD}
@ -25,4 +22,4 @@ unclassified:
Currently setting credentials causes ERROR & `Enable Push to Bintray` is not supported (always enabled). Currently setting credentials causes ERROR & `Enable Push to Bintray` is not supported (always enabled).
see [https://www.jfrog.com/jira/browse/HAP-1018] see [jfrog/HAP-1018](https://www.jfrog.com/jira/browse/HAP-1018)

View File

@ -6,7 +6,6 @@ Build agents configuration belongs (currently) under `jenkins` root element
```yaml ```yaml
jenkins: jenkins:
(...)
nodes: nodes:
- permanent: - permanent:
labelString: "linux docker test" labelString: "linux docker test"

View File

@ -1,8 +1,6 @@
jenkins: jenkins:
systemMessage: "Example of configuring credentials in Jenkins" systemMessage: "Example of configuring credentials in Jenkins"
[..]
credentials: credentials:
system: system:
domainCredentials: domainCredentials:

View File

@ -1,6 +1,6 @@
# configure Amazon EC2 plugin # configure Amazon EC2 plugin
https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Plugin [Amazon EC2 Plugin](https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Plugin)
## sample configuration ## sample configuration

View File

@ -35,6 +35,6 @@ jenkins:
numExecutors: 1 # This is just a random example entry to show that there is no "end token" for the multiline string apart from un-indent to the next YAML property. numExecutors: 1 # This is just a random example entry to show that there is no "end token" for the multiline string apart from un-indent to the next YAML property.
``` ```
# implementation note ## implementation note
The example above is only a subset of commonly used settings. The full list is available in the generated documentation. The example above is only a subset of commonly used settings. The full list is available in the generated documentation.

View File

@ -3,7 +3,7 @@ jenkins:
numExecutors: 5 numExecutors: 5
scmCheckoutRetryCount: 2 scmCheckoutRetryCount: 2
mode: NORMAL mode: NORMAL
globalNodeProperties: globalNodeProperties:
- envVars: - envVars:
env: env:
@ -36,8 +36,6 @@ jenkins:
user: "jenkins" user: "jenkins"
instanceCapStr: "10" instanceCapStr: "10"
tool: tool:
git: git:
installations: installations:
@ -45,11 +43,10 @@ tool:
home: /usr/local/bin/git home: /usr/local/bin/git
security: security:
remotingCLI: remotingCLI:
enabled: false enabled: false
unclassified: unclassified:
artifactorybuilder: artifactorybuilder:
useCredentialsPlugin: true useCredentialsPlugin: true
artifactoryServers: artifactoryServers:
@ -59,7 +56,7 @@ unclassified:
resolverCredentialsConfig: resolverCredentialsConfig:
username: artifactory_user username: artifactory_user
password: ${ARTIFACTORY_PASSWORD} password: ${ARTIFACTORY_PASSWORD}
globalLibraries: globalLibraries:
libraries: libraries:
- name: "awesome-lib" - name: "awesome-lib"

View File

@ -6,7 +6,7 @@ jobs:
organizationFolder('Bitbucket Organization Folder') { organizationFolder('Bitbucket Organization Folder') {
description("Bitbucket orga folder configured with JCasC") description("Bitbucket orga folder configured with JCasC")
displayName('My Project') displayName('My Project')
// "Projects" // "Projects"
organizations { organizations {
bitbucket { bitbucket {
@ -15,11 +15,11 @@ jobs:
repoOwner("OWN") repoOwner("OWN")
credentialsId("bitbucket-http") credentialsId("bitbucket-http")
// "Traits" ("Behaviours" in the GUI) that are "declarative-compatible" // "Traits" ("Behaviours" in the GUI) that are "declarative-compatible"
traits { traits {
webhookRegistrationTrait { webhookRegistrationTrait {
mode('ITEM') mode('ITEM')
} }
submoduleOptionTrait { submoduleOptionTrait {
extension { extension {
disableSubmodules(false) disableSubmodules(false)
@ -35,20 +35,20 @@ jobs:
} }
// "Traits" ("Behaviours" in the GUI) that are NOT "declarative-compatible" // "Traits" ("Behaviours" in the GUI) that are NOT "declarative-compatible"
// For some 'traits, we need to configure this stuff by hand until JobDSL handles it // For some 'traits, we need to configure this stuff by hand until JobDSL handles it
// https://issues.jenkins.io/browse/JENKINS-45504 // https://issues.jenkins.io/browse/JENKINS-45504
configure { node -> configure { node ->
def traits = node / navigators / 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator' / traits def traits = node / navigators / 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator' / traits
traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' { traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
strategyId('3') strategyId('3')
} }
traits << 'com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait' { traits << 'com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait' {
credentialsId('bitbucket-ssh') credentialsId('bitbucket-ssh')
} }
} }
// "Project Recognizers" // "Project Recognizers"
projectFactories { projectFactories {
workflowMultiBranchProjectFactory { workflowMultiBranchProjectFactory {

View File

@ -1,19 +1,19 @@
jobs: jobs:
- script: > - script: >
multibranchPipelineJob('image-jenkins') { multibranchPipelineJob('image-jenkins') {
branchSources { branchSources {
github { github {
scanCredentialsId('github') scanCredentialsId('github')
repoOwner('my-org') repoOwner('my-org')
repository('my-repository') repository('my-repository')
} }
} }
orphanedItemStrategy { orphanedItemStrategy {
discardOldItems { discardOldItems {
numToKeep(1) numToKeep(1)
} }
} }
triggers { triggers {
periodic(5) periodic(5)
} }
} }

View File

@ -1,21 +1,21 @@
jobs: jobs:
- script: > - script: >
folder('testjobs') folder('testjobs')
- script: > - script: >
pipelineJob('testjobs/default-agent') { pipelineJob('testjobs/default-agent') {
definition { definition {
cps { cps {
script("""\ script("""\
pipeline { pipeline {
agent any agent any
stages { stages {
stage ('test') { stage ('test') {
steps { steps {
echo "hello" echo "hello"
} }
} }
} }
}""".stripIndent()) }""".stripIndent())
} }
} }
} }

View File

@ -92,7 +92,7 @@ Master:
Now, deploy the Helm chart with those customized values: Now, deploy the Helm chart with those customized values:
``` ```bash
helm install --name jenkins stable/jenkins -f values.yaml helm install --name jenkins stable/jenkins -f values.yaml
``` ```

View File

@ -8,11 +8,11 @@ Master:
Image: "jenkins/jenkins" Image: "jenkins/jenkins"
ImageTag: "lts" ImageTag: "lts"
ImagePullPolicy: "Always" ImagePullPolicy: "Always"
# ImagePullSecret: jenkins # ImagePullSecret: jenkins
Component: "jenkins-master" Component: "jenkins-master"
UseSecurity: true UseSecurity: true
AdminUser: admin AdminUser: admin
# AdminPassword: "<defaults to random>" # AdminPassword: "<defaults to random>"
OwnSshKey: false OwnSshKey: false
# If CasC auto-reload is enabled, an SSH (RSA) keypair is needed. Can either provide your own, or leave unconfigured\false to allow a random key to be auto-generated. # If CasC auto-reload is enabled, an SSH (RSA) keypair is needed. Can either provide your own, or leave unconfigured\false to allow a random key to be auto-generated.
# If you choose to use your own, you must upload your decrypted RSA private key (not the public key above) to a Kubernetes secret using the following command: # If you choose to use your own, you must upload your decrypted RSA private key (not the public key above) to a Kubernetes secret using the following command:
@ -76,52 +76,51 @@ Master:
ContainerEnv: ContainerEnv:
InitContainerEnv: InitContainerEnv:
# Set min/max heap here if needed with: # Set min/max heap here if needed with:
# JavaOpts: "-Xms512m -Xmx512m" # JavaOpts: "-Xms512m -Xmx512m"
# Optionally configure a JMX port # Optionally configure a JMX port
# requires additional JavaOpts, ie # requires additional JavaOpts, ie
# JavaOpts: > # JavaOpts: >
# -Dcom.sun.management.jmxremote.port=4000 # -Dcom.sun.management.jmxremote.port=4000
# -Dcom.sun.management.jmxremote.authenticate=false # -Dcom.sun.management.jmxremote.authenticate=false
# -Dcom.sun.management.jmxremote.ssl=false # -Dcom.sun.management.jmxremote.ssl=false
# JMXPort: 4000 # JMXPort: 4000
# List of plugins to be install during Jenkins master start # List of plugins to be install during Jenkins master start
InstallPlugins: InstallPlugins:
- kubernetes:latest - kubernetes:latest
- kubernetes-credentials:latest - kubernetes-credentials:latest
- workflow-aggregator:latest - workflow-aggregator:latest
- workflow-job:latest - workflow-job:latest
- credentials-binding:latest - credentials-binding:latest
- git:latest - git:latest
# - saml:1.0.5 # - saml:1.0.5
# - docker-custom-build-environment:latest # - docker-custom-build-environment:latest
# Used to approve a list of groovy functions in pipelines used the script-security plugin. Can be viewed under /scriptApproval # Used to approve a list of groovy functions in pipelines used the script-security plugin. Can be viewed under /scriptApproval
# ScriptApproval: # ScriptApproval:
# - "method groovy.json.JsonSlurperClassic parseText java.lang.String" # - "method groovy.json.JsonSlurperClassic parseText java.lang.String"
# - "new groovy.json.JsonSlurperClassic" # - "new groovy.json.JsonSlurperClassic"
# List of groovy init scripts to be executed during Jenkins master start # List of groovy init scripts to be executed during Jenkins master start
InitScripts: InitScripts:
# - | # - |
# print 'adding global pipeline libraries, register properties, bootstrap jobs...' # print 'adding global pipeline libraries, register properties, bootstrap jobs...'
CustomConfigMap: false CustomConfigMap: false
ServicePort: 8080 ServicePort: 8080
# For minikube, set this to NodePort, elsewhere use LoadBalancer # For minikube, set this to NodePort, elsewhere use LoadBalancer
# Use ClusterIP if your setup includes ingress controller # Use ClusterIP if your setup includes ingress controller
ServiceType: ClusterIP ServiceType: ClusterIP
ServiceAnnotations: {} ServiceAnnotations: {}
ContainerPort: 8080 ContainerPort: 8080
SlaveListenerPort: 50000 SlaveListenerPort: 50000
LoadBalancerSourceRanges: LoadBalancerSourceRanges:
- 0.0.0.0/0 - 0.0.0.0/0
# HostName: jenkins.cicd.your.cloud # HostName: jenkins.cicd.your.cloud
Ingress: Ingress:
Enabled: false Enabled: false
# Annotations: # Annotations:
# kubernetes.io/ingress.class: nginx # kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "false" # kubernetes.io/tls-acme: "false"
# TLS: # TLS:
# - secretName: jenkins.cicd.your.cloud # - secretName: jenkins.cicd.your.cloud
# hosts: # hosts:

View File

@ -1,14 +1,14 @@
# Configure Kubernetes secrets for Jenkins Configuration as Code plugin # Configure Kubernetes secrets for Jenkins Configuration as Code plugin
### Prerequisites ## Prerequisites
1. `SECRETS` environment variable should provide a path to mounted secret volume. 1. `SECRETS` environment variable should provide a path to mounted secret volume.
2. Kubernetes secrets with all required values. 2. Kubernetes secrets with all required values.
3. `volumeMounts` and `volumes` directives of Kubernetes manifest should have records for Kubernetes secrets mounts. 3. `volumeMounts` and `volumes` directives of Kubernetes manifest should have records for Kubernetes secrets mounts.
### Sample configuration ## Sample configuration
``` ```yml
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@ -32,11 +32,9 @@ data:
--- ---
apiVersion: apps/v1beta1 apiVersion: apps/v1beta1
kind: StatefulSet kind: StatefulSet
...
spec: spec:
containers: containers:
- name: jenkins - name: jenkins
...
env: env:
# Read the configuration-as-code from the ConfigMap # Read the configuration-as-code from the ConfigMap
- name: CASC_JENKINS_CONFIG - name: CASC_JENKINS_CONFIG
@ -45,7 +43,6 @@ kind: StatefulSet
# we point Jenkins Configuration as Code plugin the location of the secrets # we point Jenkins Configuration as Code plugin the location of the secrets
- name: SECRETS - name: SECRETS
value: /secrets/jenkins value: /secrets/jenkins
...
# Mount the configuration-as-code ConfigMap # Mount the configuration-as-code ConfigMap
volumeMounts: volumeMounts:
- name: jenkins-configuration-as-code - name: jenkins-configuration-as-code
@ -53,7 +50,6 @@ kind: StatefulSet
- name: jenkins-secrets - name: jenkins-secrets
mountPath: /secrets/jenkins mountPath: /secrets/jenkins
readOnly: true readOnly: true
...
volumes: volumes:
# The configuration-as-code ConfigMap # The configuration-as-code ConfigMap
- name: jenkins-configuration-as-code - name: jenkins-configuration-as-code

View File

@ -6,7 +6,7 @@ See [config.yml](config.yml) for the `ConfigMap` definition.
Example installation on Kubernetes: Example installation on Kubernetes:
``` ```bash
kubectl apply -f service-account.yml kubectl apply -f service-account.yml
kubectl apply -f config.yml kubectl apply -f config.yml
kubectl apply -f jenkins.yml kubectl apply -f jenkins.yml

View File

@ -1,5 +1,4 @@
# jenkins # jenkins
--- ---
apiVersion: apps/v1beta1 apiVersion: apps/v1beta1
kind: StatefulSet kind: StatefulSet
@ -68,22 +67,21 @@ spec:
securityContext: securityContext:
fsGroup: 1000 fsGroup: 1000
volumes: volumes:
# The configuration-as-code ConfigMap # The configuration-as-code ConfigMap
- name: jenkins-configuration-as-code - name: jenkins-configuration-as-code
configMap: configMap:
name: jenkins-configuration-as-code name: jenkins-configuration-as-code
volumeClaimTemplates: volumeClaimTemplates:
- metadata: - metadata:
name: jenkins-home name: jenkins-home
# annotations: # annotations:
# volume.beta.kubernetes.io/storage-class: anything # volume.beta.kubernetes.io/storage-class: anything
spec: spec:
accessModes: [ "ReadWriteOnce" ] accessModes: ["ReadWriteOnce"]
resources: resources:
requests: requests:
storage: 1Gi storage: 1Gi
--- ---
apiVersion: v1 apiVersion: v1
@ -100,12 +98,10 @@ spec:
# k8s 1.7+ # k8s 1.7+
externalTrafficPolicy: Local externalTrafficPolicy: Local
ports: ports:
- - name: http
name: http
port: 80 port: 80
targetPort: 8080 targetPort: 8080
protocol: TCP protocol: TCP
- - name: agent
name: agent
port: 50000 port: 50000
protocol: TCP protocol: TCP

View File

@ -13,18 +13,18 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
metadata: metadata:
name: jenkins name: jenkins
rules: rules:
- apiGroups: [""] - apiGroups: [""]
resources: ["pods"] resources: ["pods"]
verbs: ["create","delete","get","list","patch","update","watch"] verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
- apiGroups: [""] - apiGroups: [""]
resources: ["pods/exec"] resources: ["pods/exec"]
verbs: ["create","delete","get","list","patch","update","watch"] verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
- apiGroups: [""] - apiGroups: [""]
resources: ["pods/log"] resources: ["pods/log"]
verbs: ["get","list","watch"] verbs: ["get", "list", "watch"]
- apiGroups: [""] - apiGroups: [""]
resources: ["secrets"] resources: ["secrets"]
verbs: ["get"] verbs: ["get"]
--- ---
apiVersion: rbac.authorization.k8s.io/v1beta1 apiVersion: rbac.authorization.k8s.io/v1beta1
@ -36,5 +36,5 @@ roleRef:
kind: Role kind: Role
name: jenkins name: jenkins
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: jenkins name: jenkins

View File

@ -23,5 +23,4 @@ It is identified as YAML root element `mailer` as this descriptor has a `global.
assumes it makes sense to expose it as a root element extension. assumes it makes sense to expose it as a root element extension.
Descriptor defines setters so we can inject configuration, but for SMTP authentication parameters. Descriptor defines setters so we can inject configuration, but for SMTP authentication parameters.
See https://github.com/jenkinsci/configuration-as-code-plugin/issues/2. See [jenknisci/mailer-plugin#39](https://github.com/jenkinsci/mailer-plugin/pull/39)
See https://github.com/jenkinsci/mailer-plugin/pull/39

View File

@ -5,4 +5,4 @@ jenkins:
userName: "login" userName: "login"
password: "password" password: "password"
noProxyHost: "externalhost" noProxyHost: "externalhost"
testUrl: "http://google.com" testUrl: "http://google.com"

View File

@ -1,4 +1,4 @@
jenkins: jenkins:
proxy: proxy:
name: "proxyhost" name: "proxyhost"
port: 80 port: 80

View File

@ -4,4 +4,76 @@ Basic configuration of the [Role-based Authorization Strategy plugin](https://pl
## sample ## sample
Check out the example YAML file [role-strategy-auth.yaml] which is taken from the plugins' integration test resources <https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/integrations/src/test/resources/io/jenkins/plugins/casc/RoleStrategy1.yml> ```yml
jenkins:
authorizationStrategy:
roleBased:
roles:
global:
- name: "admin"
description: "Jenkins administrators"
permissions:
- "Overall/Administer"
assignments:
- "admin"
- name: "readonly"
description: "Read-only users"
permissions:
- "Overall/Read"
- "Job/Read"
assignments:
- "authenticated"
items:
- name: "FolderA"
description: "Jobs in Folder A, but not the folder itself"
pattern: "A/.*"
permissions:
- "Job/Configure"
- "Job/Build"
- "Job/Delete"
assignments:
- "user1"
- "user2"
- name: "FolderB"
description: "Jobs in Folder B, but not the folder itself"
pattern: "B.*"
permissions:
- "Job/Configure"
- "Job/Build"
assignments:
- "user2"
agents:
- name: "Agent1"
description: "Agent 1"
pattern: "agent1"
permissions:
- "Agent/Build"
assignments:
- "user1"
securityRealm:
local:
allowsSignup: false
users:
- id: "admin"
password: "1234"
- id: "user1"
password: ""
- id: "user_hashed"
# password is password
password: "#jbcrypt:$2a$10$3bnAsorIxhl9kTYvNHa2hOJQwPzwT4bv9Vs.9KdXkh9ySANjJKm5u"
nodes:
- dumb:
mode: NORMAL
name: "agent1"
remoteFS: "/home/user1"
launcher: jnlp
- dumb:
mode: NORMAL
name: "agent2"
remoteFS: "/home/user1"
launcher: jnlp
```
which is taken from the plugins' [integration test resources](../../integrations/src/test/resources/io/jenkins/plugins/casc/RoleStrategy1.yml)

View File

@ -1,70 +0,0 @@
jenkins:
[..]
authorizationStrategy:
roleBased:
roles:
global:
- name: "admin"
description: "Jenkins administrators"
permissions:
- "Overall/Administer"
assignments:
- "admin"
- name: "readonly"
description: "Read-only users"
permissions:
- "Overall/Read"
- "Job/Read"
assignments:
- "authenticated"
items:
- name: "FolderA"
description: "Jobs in Folder A, but not the folder itself"
pattern: "A/.*"
permissions:
- "Job/Configure"
- "Job/Build"
- "Job/Delete"
assignments:
- "user1"
- "user2"
- name: "FolderB"
description: "Jobs in Folder B, but not the folder itself"
pattern: "B.*"
permissions:
- "Job/Configure"
- "Job/Build"
assignments:
- "user2"
agents:
- name: "Agent1"
description: "Agent 1"
pattern: "agent1"
permissions:
- "Agent/Build"
assignments:
- "user1"
securityRealm:
local:
allowsSignup: false
users:
- id: "admin"
password: "1234"
- id: "user1"
password: ""
- id: "user_hashed"
# password is password
password: "#jbcrypt:$2a$10$3bnAsorIxhl9kTYvNHa2hOJQwPzwT4bv9Vs.9KdXkh9ySANjJKm5u"
nodes:
- dumb:
mode: NORMAL
name: "agent1"
remoteFS: "/home/user1"
launcher: jnlp
- dumb:
mode: NORMAL
name: "agent2"
remoteFS: "/home/user1"
launcher: jnlp

View File

@ -5,9 +5,6 @@
Sample configuration for the SonarQube plugin Sample configuration for the SonarQube plugin
```yaml ```yaml
jenkins:
[...]
unclassified: unclassified:
sonarglobalconfiguration: # mandatory sonarglobalconfiguration: # mandatory
buildWrapperEnabled: true buildWrapperEnabled: true

View File

@ -1,8 +1,10 @@
# example of how to configure terraform plugin # example of how to configure terraform plugin
## Prerequisites
to test it from root of the current repository: to test it from root of the current repository:
``` ```bash
export CASC_JENKINS_CONFIG=$(PWD)/demos/terraform/jenkins.yaml export CASC_JENKINS_CONFIG=$(PWD)/demos/terraform/jenkins.yaml
mvn hpi:run mvn hpi:run
``` ```
@ -13,3 +15,44 @@ You need to install the following plugins to make it work (you can do it before
- Configuration As Code Support - Configuration As Code Support
- Job DSL - Job DSL
- SSH Credentials - SSH Credentials
## Sample
```yml
jenkins:
systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"
tool:
terraforminstallation:
installations:
- name: terraform
home: ""
properties:
- installSource:
installers:
- terraformInstaller:
id: "0.11.9-linux-amd64"
jobs:
- script: >
job("terraform-job") {
description()
keepDependencies(false)
disabled(false)
concurrentBuild(false)
wrappers {
terraformBuildWrapper {
variables("")
terraformInstallation("terraform")
doGetUpdate(true)
doNotApply(false)
doDestroy(false)
config {
value("inline")
inlineConfig("")
fileConfig("")
}
}
}
}
```

View File

@ -1,36 +0,0 @@
jenkins:
systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"
tool:
terraforminstallation:
installations:
- name: terraform
home: ""
properties:
- installSource:
installers:
- terraformInstaller:
id: '0.11.9-linux-amd64'
jobs:
- script: >
job("terraform-job") {
description()
keepDependencies(false)
disabled(false)
concurrentBuild(false)
wrappers {
terraformBuildWrapper {
variables("")
terraformInstallation("terraform")
doGetUpdate(true)
doNotApply(false)
doDestroy(false)
config {
value("inline")
inlineConfig("")
fileConfig("")
}
}
}
}

View File

@ -4,9 +4,9 @@ This document describes the JCasC API and design for plugin developers who are i
extending JCasC by implementing custom Configurators or re-using the configuration mechanism extending JCasC by implementing custom Configurators or re-using the configuration mechanism
in another context. in another context.
# Using Configuration as Code ## Using Configuration as Code
## Configurators ### Configurators
Third party code to rely on JCasC has to create a key:value hierarchical representation of the target Third party code to rely on JCasC has to create a key:value hierarchical representation of the target
component and its sub-components. This representation is defined by the `io.jenkins.plugins.casc.model` package, component and its sub-components. This representation is defined by the `io.jenkins.plugins.casc.model` package,
@ -16,7 +16,7 @@ The main API is the `Configurator` which encapsulates access to the target compo
Such a data model is exposed to external usage as a set of `Attribute`s via the `Configurator.describe()` method. Such a data model is exposed to external usage as a set of `Attribute`s via the `Configurator.describe()` method.
Each key in the key:value representation used as configuration input, has to match an `Attribute`. Each key in the key:value representation used as configuration input, has to match an `Attribute`.
## ConfigurationContext ### ConfigurationContext
The configuration process only relies on `ConfigurationContext` to convert the key:value representation into a live The configuration process only relies on `ConfigurationContext` to convert the key:value representation into a live
component instance. Third party components to use this mechanism can provide a custom context, while component instance. Third party components to use this mechanism can provide a custom context, while
@ -28,13 +28,13 @@ JCasC relies on registered Jenkins components.
- defines registry to retrieve Configurator for various component and classes to be configured - defines registry to retrieve Configurator for various component and classes to be configured
- offers option to register `Listener`s to get notified about the configuration process and react on errors - offers option to register `Listener`s to get notified about the configuration process and react on errors
## YAML support ### YAML support
`io.jenkins.plugins.casc.yaml` package defines the implementation for loading the configuration from YAML sources. `io.jenkins.plugins.casc.yaml` package defines the implementation for loading the configuration from YAML sources.
`YamlUtils.loadFrom` encapsulates the YAML parsing and merge process from a set of YAML documents, while `YamlSource` `YamlUtils.loadFrom` encapsulates the YAML parsing and merge process from a set of YAML documents, while `YamlSource`
abstracts the way we load documents from files, URLs, or any other sources. abstracts the way we load documents from files, URLs, or any other sources.
# Extending Configuration as Code ## Extending Configuration as Code
`Configurator` and `Attribute` are the core abstraction of Configuration as Code to offer implementation flexibility. `Configurator` and `Attribute` are the core abstraction of Configuration as Code to offer implementation flexibility.
JCasC offers an implementation based on introspecting Java classes, relying on web UI data-binding JCasC offers an implementation based on introspecting Java classes, relying on web UI data-binding

View File

@ -10,10 +10,10 @@ Jenkins Configuration as Code solves both problems - you don't need to access Je
We've decided to use the YAML format so writing the configuration "by hand" should be easy. Your existing Jenkins can be also used as a documentation - the YAML file tries to mimic the UI you're used to as much as possible. We've decided to use the YAML format so writing the configuration "by hand" should be easy. Your existing Jenkins can be also used as a documentation - the YAML file tries to mimic the UI you're used to as much as possible.
Plugin provides documentation generated for your specific Jenkins instance - after you install it, and it is available at: Plugin provides documentation generated for your specific Jenkins instance - after you install it, and it is available at:
http://[your_jenkins_url]/configuration-as-code/ `http://[your_jenkins_url]/configuration-as-code/`
Various samples of plugins' configuration can be found in [demos](../demos) folder Various samples of plugins' configuration can be found in [demos](../demos) folder
## Export existing configuration ## Export existing configuration
To be able to do that, you need to install the plugin manually on your working Jenkins instance and use the export function under http://[your_jenkins_url]/configuration-as-code/. Please note that export is not intended to offer a directly usable jenkins.yaml configuration. It can be used for inspiration writing your own, but be aware that export can be partial, or fail for some components. To be able to do that, you need to install the plugin manually on your working Jenkins instance and use the export function under `http://[your_jenkins_url]/configuration-as-code/`. Please note that export is not intended to offer a directly usable jenkins.yaml configuration. It can be used for inspiration writing your own, but be aware that export can be partial, or fail for some components.

View File

@ -68,22 +68,22 @@
## Run it ## Run it
1. Set execute permissions on the newly created scripts: `chmod u+x run-consul-agent.sh` - Set execute permissions on the newly created scripts: `chmod u+x run-consul-agent.sh`
1. Set execute permissions on the newly created scripts: `chmod u+x run-vault-server.sh` - Set execute permissions on the newly created scripts: `chmod u+x run-vault-server.sh`
1. Execute: `./run-consul-agent.sh` to start the consul agent locally - Execute: `./run-consul-agent.sh` to start the consul agent locally
- Verify that the consul agent is up and running, connected to the cluster. - Verify that the consul agent is up and running, connected to the cluster.
1. Execute: `./run-vault-server.sh` to start the vault server - Execute: `./run-vault-server.sh` to start the vault server
1. Configure the vault server - Configure the vault server
- Execute: `docker exec -it vault /bin/sh` to access the vault docker container - Execute: `docker exec -it vault /bin/sh` to access the vault docker container
- Execute: `vault operator init` to initialize the vault server. Take note of the _Unseal Keys_ and the _Initial Root Token_. Without these, the vault is lost when sealed/locked - Execute: `vault operator init` to initialize the vault server. Take note of the _Unseal Keys_ and the _Initial Root Token_. Without these, the vault is lost when sealed/locked
- Execute: `vault operator unseal` to unseal/open the vault. Follow the onscreen instructions and use 3 of the five _Unseal Keys_ - Execute: `vault operator unseal` to unseal/open the vault. Follow the onscreen instructions and use 3 of the five _Unseal Keys_
- Execute: `exit` to log out of the vault docker container - Execute: `exit` to log out of the vault docker container
## Test it ## Test it
1. Execute: `export VAULT_TOKEN="[VAULT_TOKEN]"` where _Vault Token_ is used - Execute: `export VAULT_TOKEN="[VAULT_TOKEN]"` where _Vault Token_ is used
1. Execute: `curl --header "X-Vault-Token: $VAULT_TOKEN" --request POST --data '{"bar": "Baz"}' http://vault.domain.local:8200/v1/secret/foo` to put test data into the vault. No output is returned if it works - Execute: `curl --header "X-Vault-Token: $VAULT_TOKEN" --request POST --data '{"bar": "Baz"}' http://vault.domain.local:8200/v1/secret/foo` to put test data into the vault. No output is returned if it works
1. Execute: `curl --header "X-Vault-Token: $VAULT_TOKEN" http://vault.domain.local:8200/v1/secret/foo` to get test data from the vault. Expected output is JSON formatted: - Execute: `curl --header "X-Vault-Token: $VAULT_TOKEN" http://vault.domain.local:8200/v1/secret/foo` to get test data from the vault. Expected output is JSON formatted:
```json ```json
{ {

View File

@ -1,13 +1,12 @@
jenkins: jenkins:
securityRealm: securityRealm:
activeDirectory: activeDirectory:
domains: domains:
- name: "acme" - name: "acme"
servers: "ad1.acme.com:123,ad2.acme.com:456" servers: "ad1.acme.com:123,ad2.acme.com:456"
site: "site" site: "site"
bindName: "admin" bindName: "admin"
bindPassword: "${BIND_PASSWORD}" bindPassword: "${BIND_PASSWORD}"
groupLookupStrategy: "RECURSIVE" groupLookupStrategy: "RECURSIVE"
removeIrrelevantGroups: true removeIrrelevantGroups: true
customDomain: true customDomain: true
@ -17,4 +16,4 @@ jenkins:
startTls: true startTls: true
tlsConfiguration: JDK_TRUSTSTORE tlsConfiguration: JDK_TRUSTSTORE
internalUsersDatabase: internalUsersDatabase:
jenkinsInternalUser: "jenkins" jenkinsInternalUser: "jenkins"

View File

@ -3,7 +3,7 @@ jenkins:
credentials: credentials:
system: system:
domainCredentials: domainCredentials:
- domain : - domain:
name: "test.com" name: "test.com"
description: "test.com domain" description: "test.com domain"
specifications: specifications:
@ -11,7 +11,7 @@ credentials:
includes: "*.test.com" includes: "*.test.com"
credentials: credentials:
- usernamePassword: - usernamePassword:
scope: SYSTEM scope: SYSTEM
id: user1 id: user1
username: Administrator username: Administrator
password: secret password: secret

View File

@ -5,8 +5,8 @@ tool:
home: "" home: ""
properties: properties:
- installSource: - installSource:
- command: - command:
toolHome: "/bin/my-tool" toolHome: "/bin/my-tool"
command: > command: >
curl -o my-tool.tar.bz2 -L https://github.com/my/tool/releases/download/v0.1.0/linux-amd64-my-tool.tar.bz2 curl -o my-tool.tar.bz2 -L https://github.com/my/tool/releases/download/v0.1.0/linux-amd64-my-tool.tar.bz2
tar -xvjf my-tool.tar.bz2 tar -xvjf my-tool.tar.bz2

View File

@ -21,4 +21,4 @@ jenkins:
user: "jenkins" user: "jenkins"
instanceCapStr: "10" instanceCapStr: "10"
retentionStrategy: retentionStrategy:
idleMinutes: 1 idleMinutes: 1

View File

@ -34,4 +34,4 @@ jenkins:
connector: connector:
attach: attach:
user: "jenkins" user: "jenkins"
instanceCapStr: "5" instanceCapStr: "5"

View File

@ -9,10 +9,10 @@ jenkins:
unclassified: unclassified:
metricsaccesskey: metricsaccesskey:
accessKeys: accessKeys:
- key: "evergreen" - key: "evergreen"
description: "Key for evergreen health-check" description: "Key for evergreen health-check"
canHealthCheck: true canHealthCheck: true
canPing: false canPing: false
canThreadDump: false canThreadDump: false
canMetrics: false canMetrics: false
origins: "*" origins: "*"

View File

@ -10,10 +10,10 @@ credentials:
unclassified: unclassified:
gitlabconnectionconfig: gitlabconnectionconfig:
connections: connections:
- apiTokenId: gitlab_token - apiTokenId: gitlab_token
clientBuilderId: "autodetect" clientBuilderId: "autodetect"
connectionTimeout: 20 connectionTimeout: 20
ignoreCertificateErrors: true ignoreCertificateErrors: true
name: "my_gitlab_server" name: "my_gitlab_server"
readTimeout: 10 readTimeout: 10
url: "https://gitlab.com/" url: "https://gitlab.com/"

View File

@ -5,4 +5,3 @@ tool:
home: /bin/git home: /bin/git
- name: another_git - name: another_git
home: /usr/local/bin/git home: /usr/local/bin/git

View File

@ -5,4 +5,4 @@ jenkins:
githubApiUri: "https://api.github.com" githubApiUri: "https://api.github.com"
clientID: "someId" clientID: "someId"
clientSecret: "${GITHUB_SECRET}" clientSecret: "${GITHUB_SECRET}"
oauthScopes: "read:org,user:email" oauthScopes: "read:org,user:email"

View File

@ -14,7 +14,7 @@ credentials:
scope: SYSTEM scope: SYSTEM
id: agent-private-key id: agent-private-key
username: agentuser username: agentuser
passphrase: password passphrase: password
description: "ssh private key used to connect ssh slaves" description: "ssh private key used to connect ssh slaves"
privateKeySource: privateKeySource:
directEntry: directEntry:

View File

@ -6,4 +6,4 @@ unclassified:
modernSCM: modernSCM:
scm: scm:
git: git:
remote: "https://github.com/jenkins-infra/pipeline-library.git" remote: "https://github.com/jenkins-infra/pipeline-library.git"

View File

@ -7,12 +7,11 @@ jenkins:
local: local:
allowsSignup: false allowsSignup: false
users: users:
- id: test - id: test
password: test password: test
authorizationStrategy: authorizationStrategy:
globalMatrix: globalMatrix:
grantedPermissions: grantedPermissions:
- "Overall/Read:anonymous" - "Overall/Read:anonymous"
- "Overall/Administer:authenticated" - "Overall/Administer:authenticated"

View File

@ -1,3 +1,3 @@
security: security:
GlobalJobDslSecurityConfiguration: GlobalJobDslSecurityConfiguration:
useScriptSecurity: false useScriptSecurity: false

View File

@ -1,5 +1,4 @@
jenkins: jenkins:
securityRealm: securityRealm:
ldap: ldap:
configurations: configurations:
@ -10,4 +9,4 @@ jenkins:
size: 100 size: 100
ttl: 10 ttl: 10
userIdStrategy: CaseInsensitive userIdStrategy: CaseInsensitive
groupIdStrategy: CaseSensitive groupIdStrategy: CaseSensitive

View File

@ -3,4 +3,4 @@ unclassified:
adminAddress: admin@acme.org adminAddress: admin@acme.org
replyToAddress: do-not-reply@acme.org replyToAddress: do-not-reply@acme.org
#smtpHost: smtp.acme.org #smtpHost: smtp.acme.org
smtpPort: 4441 smtpPort: 4441

View File

@ -7,12 +7,11 @@ jenkins:
local: local:
allowsSignup: false allowsSignup: false
users: users:
- id: test - id: test
password: test password: test
authorizationStrategy: authorizationStrategy:
projectMatrix: projectMatrix:
grantedPermissions: grantedPermissions:
- "Overall/Read:anonymous" - "Overall/Read:anonymous"
- "Overall/Administer:authenticated" - "Overall/Administer:authenticated"

View File

@ -1,5 +1,4 @@
jenkins: jenkins:
authorizationStrategy: authorizationStrategy:
roleBased: roleBased:
roles: roles:

View File

@ -1,5 +1,4 @@
jenkins: jenkins:
authorizationStrategy: authorizationStrategy:
roleBased: roleBased:
roles: roles:

View File

@ -12,4 +12,4 @@ jobs:
} }
} }
- file: ./src/test/resources/io/jenkins/plugins/casc/testJob2.groovy - file: ./src/test/resources/io/jenkins/plugins/casc/testJob2.groovy

View File

@ -1,13 +1,13 @@
jobs: jobs:
- script: > - script: >
job('seedJobWithEnvVars') { job('seedJobWithEnvVars') {
scm { scm {
git("$REPO_URL") git("$REPO_URL")
} }
triggers { triggers {
scm('H/15 * * * *') scm('H/15 * * * *')
} }
steps { steps {
maven('-e clean test') maven('-e clean test')
} }
} }

View File

@ -10,4 +10,4 @@ unclassified:
triggers: triggers:
skipScmCause: true skipScmCause: true
skipUpstreamCause: true skipUpstreamCause: true
envVar: "envVar" envVar: "envVar"

View File

@ -1,7 +1,7 @@
credentials: credentials:
system: system:
domainCredentials: domainCredentials:
- domain : - domain:
name: "test.com" name: "test.com"
description: "test.com domain" description: "test.com domain"
specifications: specifications:
@ -9,16 +9,16 @@ credentials:
includes: "*.test.com" includes: "*.test.com"
credentials: credentials:
- usernamePassword: - usernamePassword:
scope: SYSTEM scope: SYSTEM
id: sudo_password id: sudo_password
username: root username: root
password: ${SUDO_PASSWORD} password: ${SUDO_PASSWORD}
# global credentials # global credentials
- credentials: - credentials:
- certificate: - certificate:
scope: SYSTEM scope: SYSTEM
id: ssh_private_key id: ssh_private_key
password: ${SSH_KEY_PASSWORD} password: ${SSH_KEY_PASSWORD}
keyStoreSource: keyStoreSource:
fileOnMaster: fileOnMaster:
@ -41,8 +41,3 @@ credentials:
privateKeySource: privateKeySource:
directEntry: directEntry:
privateKey: ${SSH_PRIVATE_KEY} privateKey: ${SSH_PRIVATE_KEY}

View File

@ -7,5 +7,5 @@ tool:
- installSource: - installSource:
installers: installers:
- jdkInstaller: - jdkInstaller:
id: 'jdk-8u181-oth-JPR' id: "jdk-8u181-oth-JPR"
acceptLicense: true acceptLicense: true

View File

@ -8,4 +8,4 @@ jenkins:
name: "qix" name: "qix"
# see https://github.com/jenkinsci/jenkins/pull/3475 # see https://github.com/jenkinsci/jenkins/pull/3475
# - permanent: # - permanent:
# name: "zot" # name: "zot"

View File

@ -1,3 +1,2 @@
securityConfig: securityConfig:
markupFormatter: plainText markupFormatter: plainText

View File

@ -1,3 +1,3 @@
jenkins: jenkins:
systemMessage: "configuration as code - JenkinsConfigTest" systemMessage: "configuration as code - JenkinsConfigTest"
quietPeriod: 10 quietPeriod: 10

View File

@ -8,4 +8,4 @@ jenkins:
- id: "hashedadmin" - id: "hashedadmin"
# password is 'password' # password is 'password'
password: "#jbcrypt:$2a$10$LP4bMhwyCPnsDm.XRcTZSuBqWYKGAiDAsQXrSrJGYcEd9padaPgsC" password: "#jbcrypt:$2a$10$LP4bMhwyCPnsDm.XRcTZSuBqWYKGAiDAsQXrSrJGYcEd9padaPgsC"
authorizationStrategy: loggedInUsersCanDoAnything authorizationStrategy: loggedInUsersCanDoAnything

View File

@ -9,5 +9,5 @@ tool:
properties: properties:
- installSourceProperty: - installSourceProperty:
installers: installers:
- mavenInstaller: - mavenInstaller:
id: '3.5.0' id: "3.5.0"

View File

@ -5,4 +5,4 @@ jenkins:
userName: "login" userName: "login"
password: "password" password: "password"
noProxyHost: "externalhost" noProxyHost: "externalhost"
testUrl: "http://google.com" testUrl: "http://google.com"

View File

@ -1,4 +1,4 @@
jenkins: jenkins:
proxy: proxy:
name: "proxyhost" name: "proxyhost"
port: 80 port: 80

View File

@ -3,4 +3,4 @@ jenkins:
- envVars: - envVars:
env: env:
- key: FOO - key: FOO
value: BAR value: BAR

View File

@ -2,4 +2,4 @@ jenkins:
securityRealm: securityRealm:
local: local:
allowsSignup: false allowsSignup: false
authorizationStrategy: unsecured authorizationStrategy: unsecured

View File

@ -28,9 +28,9 @@ jenkins:
- "lastDuration" - "lastDuration"
- "buildButton" - "buildButton"
name: "other list view" name: "other list view"
# Currently not possible due to missing getter/setter in Jenkins Core # Currently not possible due to missing getter/setter in Jenkins Core
# jobNames: # jobNames:
# - "testJob1" # - "testJob1"
viewsTabBar: "standard" viewsTabBar: "standard"
authorizationStrategy: "loggedInUsersCanDoAnything" authorizationStrategy: "loggedInUsersCanDoAnything"
securityRealm: securityRealm:

View File

@ -3,9 +3,9 @@ jenkins:
local: local:
allowsSignup: false allowsSignup: false
users: users:
- id: admin - id: admin
password: ${adminpw:-passw0rd} password: ${adminpw:-passw0rd}
authorizationStrategy: authorizationStrategy:
globalMatrix: globalMatrix:
grantedPermissions: grantedPermissions:
- "Overall/Administer:authenticated" - "Overall/Administer:authenticated"

View File

@ -4,4 +4,4 @@ jenkins:
nodes: nodes:
- dumb: - dumb:
mode: NORMAL mode: NORMAL
name: "agent1" name: "agent1"