Skip to content

Commit ba723ae

Browse files
FNSdevVivian Noronhatimjatorstenwalter
authored
Add a simple example for JCasC in the docs (#32)
* docs(jenkins): add a simple example for JCasC in the docs Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * docs(jenkins): make simple JCasC configuration example in values.yaml more accurate Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * bump chart version Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * update k8s sidecar image to 0.1.193 Signed-off-by: Vivian Noronha <vivian.noronha@syncier.com> Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * add commit message to changelog Signed-off-by: Vivian Noronha <vivian.noronha@syncier.com> Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * Add timja as maintainer Signed-off-by: Tim Jacomb <timjacomb1+github@gmail.com> Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * Bump chart version Signed-off-by: Tim Jacomb <timjacomb1+github@gmail.com> Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * add issue and pull request templates (#37) * add issue and pull request templates Signed-off-by: Torsten Walter <mail@torstenwalter.de> * fixed typo Signed-off-by: Torsten Walter <mail@torstenwalter.de> Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * docs(jenkins): update configScripts example Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * docs(jenkins): add 2.6.5 entry into changelog Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * chart(jenkins): bump chart version to 2.6.5 Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> * docs(jenkins): fix 'configAutoReload' property name in README Signed-off-by: Uladzislau Stasheuski <fnsdevelopment@gmail.com> Co-authored-by: Vivian Noronha <vivian.noronha@syncier.com> Co-authored-by: Tim Jacomb <timjacomb1+github@gmail.com> Co-authored-by: Torsten Walter <mail@torstenwalter.de>
1 parent f251fce commit ba723ae

File tree

4 files changed

+60
-18
lines changed

4 files changed

+60
-18
lines changed

charts/jenkins/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Use the following links to reference issues, PRs, and commits prior to v2.6.0.
1010

1111
The change log until v1.5.7 was auto-generated based on git commits. Those entries include a reference to the git commit to be able to get more details.
1212

13+
## 2.6.5
14+
Update configScripts example
15+
1316
## 2.6.4
1417

1518
Add timja as a maintainer

charts/jenkins/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
name: jenkins
33
home: https://jenkins.io/
4-
version: 2.6.4
4+
version: 2.6.5
55
appVersion: lts
66
description: Open source continuous integration server. It supports multiple SCM tools
77
including CVS, Subversion and Git. It can execute Apache Ant and Apache Maven-based

charts/jenkins/README.md

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,68 @@ Each key will become the name of a configuration yaml file on the master in /var
8181
The lines after each `|` become the content of the configuration yaml file.
8282
The first line after this is a JCasC root element, e.g. jenkins, credentials, etc.
8383
Best reference is the Documentation link here: `https://<jenkins_url>/configuration-as-code`.
84-
The example below creates ldap settings:
84+
85+
The example below sets custom systemMessage:
86+
87+
```yaml
88+
master:
89+
JCasC:
90+
configScripts:
91+
welcome-message: |
92+
jenkins:
93+
systemMessage: Welcome to our CI\CD server.
94+
```
95+
96+
More complex example that creates ldap settings:
97+
98+
```yaml
99+
master:
100+
JCasC:
101+
configScripts:
102+
ldap-settings: |
103+
jenkins:
104+
securityRealm:
105+
ldap:
106+
configurations:
107+
- server: ldap.acme.com
108+
rootDN: dc=acme,dc=uk
109+
managerPasswordSecret: ${LDAP_PASSWORD}
110+
groupMembershipStrategy:
111+
fromUserRecord:
112+
attributeName: "memberOf"
113+
```
114+
115+
Keep in mind that default configuration file already contains some values that you won't be able to override under configScripts section.
116+
117+
For example, you can not configure Jenkins URL and System Admin e-mail address like this because of conflictig configuration error.
118+
119+
Incorrect:
85120
86121
```yaml
87-
configScripts:
88-
ldap-settings: |
89-
jenkins:
90-
securityRealm:
91-
ldap:
92-
configurations:
93-
- server: ldap.acme.com
94-
rootDN: dc=acme,dc=uk
95-
managerPasswordSecret: ${LDAP_PASSWORD}
96-
groupMembershipStrategy:
97-
fromUserRecord:
98-
attributeName: "memberOf"
122+
master:
123+
JCasC:
124+
configScripts:
125+
jenkins-url: |
126+
unclassified:
127+
location:
128+
url: https://example.com/jenkins
129+
adminAddress: example@mail.com
130+
```
131+
132+
Correct:
133+
134+
```yaml
135+
master:
136+
jenkinsUrl: https://example.com/jenkins
137+
jenkinsAdminEmail: example@mail.com
99138
```
100139
101140
Further JCasC examples can be found [here](https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos).
102141
103142
#### Config as Code With or Without Auto-Reload
104143
105144
Config as Code changes (to `master.JCasC.configScripts`) can either force a new pod to be created and only be applied at next startup, or can be auto-reloaded on-the-fly.
106-
If you set `master.sidecars.autoConfigReload.enabled` to `true`, a second, auxiliary container will be installed into the Jenkins master pod, known as a "sidecar".
145+
If you set `master.sidecars.configAutoReload.enabled` to `true`, a second, auxiliary container will be installed into the Jenkins master pod, known as a "sidecar".
107146
This watches for changes to configScripts, copies the content onto the Jenkins file-system and issues a POST to `http://<jenkins_url>/reload-configuration-as-code` with a pre-shared key.
108147
You can monitor this sidecar's logs using command `kubectl logs <master_pod> -c jenkins-sc-config -f`.
109148
If you want to enable auto-reload then you also need to configure rbac as the container which triggers the reload needs to watch the config maps:

charts/jenkins/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ master:
279279
enabled: true
280280
defaultConfig: true
281281
configScripts: {}
282+
# welcome-message: |
283+
# jenkins:
284+
# systemMessage: Welcome to our CI\CD server. This Jenkins is configured and managed 'as code'.
282285
# Ignored if securityRealm is defined in master.JCasC.configScripts and
283286
# ignored if master.enableXmlConfig=true as master.securityRealm takes precedence
284287
securityRealm: |-
@@ -288,9 +291,6 @@ master:
288291
authorizationStrategy: |-
289292
loggedInUsersCanDoAnything:
290293
allowAnonymousRead: false
291-
# welcome-message: |
292-
# jenkins:
293-
# systemMessage: Welcome to our CI\CD server. This Jenkins is configured and managed 'as code'.
294294
# Optionally specify additional init-containers
295295
customInitContainers: []
296296
# - name: custom-init

0 commit comments

Comments
 (0)