Commit Graph

68 Commits

Author SHA1 Message Date
Florian Klink
70808d0217 nixos/jenkins: set StateDirectory if home is /var/lib/jenkins
This will cause systemd to chown /var/lib/jenkins to the user that
the jenkins systemd service runs as, fixing permission issues when
mounting /var/lib/jenkins from another data volume.

It uses the same logic that garage is using, too, checking for the
prefix.
2023-12-13 15:15:50 +02:00
h7x4
0a37316d6c
treewide: use mkPackageOption
This commit replaces a lot of usages of `mkOption` with the package
type, to be `mkPackageOption`, in order to reduce the amount of code.
2023-11-27 01:28:36 +01:00
Felix Bühler
0a2745684e
Merge pull request #239624 from Stunkymonkey/use-optionalString-then
treewide: use optionalString instead of 'then ""'
2023-07-22 13:02:47 +02:00
Emily
d8c2229c49
Merge pull request #226684 from srid/patch-8
nixos/jenkins-job-builder: Fix link to documentation, use mkEnableOption
2023-07-02 19:49:17 +02:00
Sridhar Ratnakumar
ac4790a84e
nixos/jenkins-job-builder: Fix link to documentation, use mkEnableOption
Co-Authored-By: emilylange <git@emilylange.de>
2023-07-02 19:07:44 +02:00
Felix Buehler
f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
Felix Buehler
327b0cff7a treewide: use more lib.optionalString 2023-04-07 13:38:33 +02:00
Bjørn Forsman
fcf81f91a3 nixos/jenkins-job-builder: better defaults for accessUser/accessTokenFile
The new defaults allows jenkins-job-builder to reload the configuration
out-of-the-box, whereas the previous defaults required users to manually
reload/restart jenkins, or configure accessUser/accessTokenFile
themselves.

(If `extraJavaOptions = [ "-Djenkins.install.runSetupWizard=false" ]`
then the initial admin user is *not* created and you have to use JCasC
or something else to bootstrap.)
2022-10-30 19:01:48 +01:00
ajs124
18a17d11ff nixos/jenkins: jdk11 -> jdk17
see https://www.jenkins.io/doc/upgrade-guide/2.361/
we'll need to do this eventually, not sure when the best point in time is
2022-10-11 21:16:37 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Bjørn Forsman
16108ff74a nixos/jenkins-job-builder: set serviceConfig.Type = "oneshot"
This change allows detecting configuration errors during
switch-to-configuration instead of them being reported asynchronously
*after* switch-to-configuration has exited.

(And update the NixOS test accordingly.)
2022-07-23 13:30:53 +02:00
Bjørn Forsman
0080a93cdf nixos/jenkins-job-builder: create secret file with umask 0077
IOW, don't make it world readable.
2022-07-17 15:24:48 +02:00
Bjørn Forsman
50eaf82b6f nixos/jenkins-job-builder: fix jenkins authentication
The current authentication code is broken against newer jenkins:

  jenkins-job-builder-start[1257]: Asking Jenkins to reload config
  jenkins-start[789]: 2022-07-12 14:34:31.148+0000 [id=17]        WARNING hudson.security.csrf.CrumbFilter#doFilter: Found invalid crumb 31e96e52938b51f099a61df9505a4427cb9dca7e35192216755659032a4151df. If you are calling this URL with a script, please use the API Token instead. More information: https://www.jenkins.io/redirect/crumb-cannot-be-used-for-script
  jenkins-start[789]: 2022-07-12 14:34:31.160+0000 [id=17]        WARNING hudson.security.csrf.CrumbFilter#doFilter: No valid crumb was included in request for /reload by admin. Returning 403.
  jenkins-job-builder-start[1357]: curl: (22) The requested URL returned error: 403

Fix it by using `jenkins-cli` instead of messing with `curl`.

This rewrite also prevents leaking the password in process listings. (We
could probably do it without `replace-secret`, assuming `printf` is a
shell built-in, but this implementation should be safe even with shells
not having a built-in `printf`.)

Ref https://github.com/NixOS/nixpkgs/issues/156400.
2022-07-16 12:30:41 +02:00
P. R. d. O
eeb3206a29 nixos/jenkinsSlave: install java
Installs Java into the Jenkins agent and allows specifying the JDK/JRE package to use. This is necessary as Jenkins verifies if the agent contains Java installed through the java -fullversion command, which if not, the connection will fail.
2022-04-01 22:11:18 +02:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Daniel Nagy
79a86e7ef5
treewide: Port type adaptations 2021-08-11 00:45:08 +02:00
Franz Pletz
f73efb9fb3
Merge pull request #121841 from Pamplemousse/jenkins-cli
jenkins: Create the `jenkins-cli` command
2021-07-06 14:45:29 +00:00
Pamplemousse
4265efef54 nixos/modules/jenkins: Add option to add CLI
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
2021-06-14 20:16:20 -07:00
Bjørn Forsman
4bcb22e17a nixos/jenkins-job-builder: add support for folder jobs
Add support for folder jobs
(https://plugins.jenkins.io/cloudbees-folder/) by reworking the service
to support nested jobs.

This also fixes this deprecation warning (as a happy side effect):

  WARNING:jenkins_jobs.cli.subcommand.test:(Deprecated) The default output behavior of `jenkins-jobs test` when given the --output flag will change in JJB 3.0. Instead of writing jobs to OUTPUT/jobname; they will be written to OUTPUT/jobname/config.xml. The new behavior can be enabled by the passing `--config-xml` parameter
2021-06-03 19:29:57 +02:00
Augustin Borsu
685ae84cb0 nixos/jenkins: switch to openjdk11 as openjdk14 is not supported 2020-10-04 11:45:02 +02:00
worldofpeace
2af959e579 nixos/jenkins/slave: fix eval 2020-01-12 15:17:05 -05:00
rnhmjoj
1d61efb7f1 treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
Alex Whitt
f01224374d nixos/jenkins: Copy plugins as .jpi to fix initialization errors 2019-09-17 19:54:57 +02:00
Daniel Schaefer
786f02f7a4 treewide: Remove usage of isNull
isNull "is deprecated; just write e == null instead" says the Nix manual
2019-04-29 14:05:50 +02:00
Bjørn Forsman
bb94d419fb nixos/jenkins-job-builder: add accessTokenFile option
The new option allows storing the secret access token outside the world
readable Nix store.
2018-12-03 17:07:29 +01:00
Bjørn Forsman
8ebfd5c45c nixos/jenkins-job-builder: stop reloadScript on error
Currently there are two calls to curl in the reloadScript, neither which
check for errors. If something is misconfigured (like wrong authToken),
the only trace that something wrong happened is this log message:

  Asking Jenkins to reload config
  <h1>Bad Message 400</h1><pre>reason: Illegal character VCHAR='<'</pre>

The service isn't marked as failed, so it's easy to miss.

Fix it by passing --fail to curl.

While at it:
* Add $curl_opts and $jenkins_url variables to keep the curl command
  lines DRY.
* Add --show-error to curl to show short error message explanation when
  things go wrong (like HTTP 401 error).
* Lower-case the $CRUMB variable as upper case is for exported environment
  variables.

The new behaviour, when having wrong accessToken:

  Asking Jenkins to reload config
  curl: (22) The requested URL returned error: 401

And the service is clearly marked as failed in `systemctl --failed`.
2018-12-03 17:07:29 +01:00
volth
2e979e8ceb [bot] nixos/*: remove unused arguments in lambdas 2018-07-20 20:56:59 +00:00
Florian Klink
fff5923686 nixos/modules: users.(extraUsers|extraGroup->users|group) 2018-06-30 03:02:58 +02:00
Corey O'Connor
28a55f5bd6 jenkins: Add "java.awt.headless=true" to JDK options.
This is consistent with the recommended jenkins startup script. See:

* https://wiki.jenkins.io/display/JENKINS/JenkinsLinuxStartupScript
2018-03-17 22:16:59 -07:00
Corey O'Connor
241160aacc jenkins: Include Deja-Vu fonts in system environment to silence jenkins warning. 2018-03-17 22:16:26 -07:00
Bjørn Forsman
5de8f99f03 nixos/jenkins: ensure postStart follows redirects
Pass the -L flag to curl to make it follow redirects. This fixes an
issue I found when setting up reverse proxy for Jenkins. Without this
fix, the returned HTTP code was stuck at 302, making postStart fail the
service (it expects 200 or 403).
2018-03-02 08:48:38 +01:00
James Earl Douglas
aae32e15af
nixos/jenkins: add an option for the package
This allows NixOS configuration to specify the desired Jenkins package.
2017-10-20 01:16:12 +02:00
Niklas Hambüchen
aa645b51ba jenkins service: Add extraJavaOptions.
This is useful for the common case of passing arguments to
the JVM that runs Jenkins.
2017-06-16 09:23:11 +02:00
Mateusz Kowalczyk
cb5cb0bf95 services.jenkins.plugins: fix initial case 2017-05-22 12:01:27 +01:00
Mateusz Kowalczyk
41ea71a347 jenkins service: add declarative plugin support 2017-05-20 22:54:07 +01:00
Wei Tang
99013f853a
jenkins-job-builder: allow setting access tokens for reloading 2017-03-06 07:57:01 -05:00
Bjørn Forsman
8c2d888401 jenkins: move $out/{lib => webapps}/jenkins.war
As pointed out by @danbst, the tomcat NixOS module expects packages
listed in services.tomcat.webapps to either be direct .war file paths or
have .war files inside a "webapps" directory.

Commit 4075c10a59
("jenkins: move .war file from $out to $out/lib/jenkins.war") broke
jenkins + tomcat. Fix it by moving jenkins.war to $out/webapps/.
2016-07-15 17:18:44 +02:00
Bjørn Forsman
4075c10a59 jenkins: move .war file from $out to $out/lib/jenkins.war
Fixes #14137, also known as:

  $ nix-shell -p jenkins
  bash: source: /nix/store/ln1yw6c2v8bb2cjqfr1z5aqcssw054wa-jenkins-2.3:
  cannot execute binary file
  [nix-shell exited with error]

The problem is that jenkins.war is not installed inside the directory
$out, but rather _as the file_ $out. Fix it by moving the file to
$out/lib/jenkins.war.

While at it, move buildCommand so that the "meta" section is at the end
of the expression (standard style), and quote shell variables.
2016-07-15 15:12:52 +02:00
Franz Pletz
939c80c26f jenkins module: Check for 200 & 403 response codes
The new jenkins version shows a setup wizard on first startup that will
throw a 403 HTTP response code instead of 200.
2016-05-13 17:45:39 +02:00
Bjørn Forsman
78b6e8c319 jenkins service: improve curl call in postStart
* Perform HTTP HEAD request instead of full GET (lighter weight)
* Don't log output of curl to the journal (it's noise/debug)
* Use explicit http:// URL scheme
* Reduce poll interval from 10s to 2s (respond to state changes
  quicker). Probably not relevant on boot (lots of services compete for
  the CPU), but online service restarts/reloads should be quicker.
* Pass --fail to curl (should be more robust against false positives)
* Use 4 space indent for shell code.
2016-05-03 23:12:45 +02:00
Bjørn Forsman
51e5beca42 jenkins service: remove unneeded (and brittle) part of postStart
The current postStart code holds Jenkins off the "started" state until
Jenkins becomes idle. But it should be enough to wait until Jenkins
start handling HTTP requests to consider it "started".

More reasons why the current approach is bad and we should remove it,
from @coreyoconnor in
https://github.com/NixOS/nixpkgs/issues/14991#issuecomment-216572571:

  1. Repeatedly curling for a specific human-readable string to
  determine "Active" is fragile. For instance, what happens when jenkins
  is localized?

  2. The time jenkins takes to initializes is variable. This (at least
  used to) depend on the number of jobs and any plugin upgrades requested.

  3. Jenkins can be requested to restart from the UI. Which will not
  affect the status of the service. This means that the service being
  "active" does not imply jenkins is initialized. Downstream services
  cannot assume jenkins is initialized if the service is active. Might
  as well accept that and remove the initialized test from service
  startup.

Fixes #14991.
2016-05-03 22:24:13 +02:00
Vladimír Čunát
09af15654f Merge master into closure-size
The kde-5 stuff still didn't merge well.
I hand-fixed what I saw, but there may be more problems.
2016-03-08 09:58:19 +01:00
Guillaume Maudoux
9f358f809d Configure a default trust store for openssl 2016-02-03 12:42:01 +01:00
Vladimír Čunát
716aac2519 Merge branch 'staging' into closure-size 2016-01-19 09:55:31 +01:00
Thomas Strobel
a04a7272aa Add missing 'type', 'defaultText' and 'literalExample' in module definitions
- add missing types in module definitions
- add missing 'defaultText' in module definitions
- wrap example with 'literalExample' where necessary in module definitions
2016-01-17 19:41:23 +01:00
Vladimír Čunát
f9f6f41bff Merge branch 'master' into closure-size
TODO: there was more significant refactoring of qtbase and plasma 5.5
on master, and I'm deferring pointing to correct outputs to later.
2015-12-31 09:53:02 +01:00
Bjørn Forsman
b2d0886b37 nixos/jenkins: fix typo in docstring (s/adress/address/) 2015-12-23 23:49:01 +01:00
Bjørn Forsman
c6b251f5d5 nixos/jenkins: rename option 'host' to 'listenAddress'
I think the name 'listenAddress' is more descriptive. Other NixOS
modules that define 'host' either use it as listen address or as address
a client connects to. listenAddress is unambiguous.

The addition of 'host' was added earlier today[1], so not bothering with
./nixos/modules/rename.nix.

[1]: 44ea184997 ("jenkins ci enhancement: add port and prefix option")
2015-12-23 23:48:49 +01:00
Augustin Borsu
1c120c55fb jenkins-job-builder fix: use prefix and host from jenkins cfg, fixes #11897 2015-12-23 11:39:32 +01:00
Augustin Borsu
44ea184997 jenkins ci enhancement: add port and prefix option
As named these options enable to specify a bind host and url prefix
to be used by jenkins. Adding these options in the config rather than
using extra arguments allows us to re-use those information in other
services using jenkins such as jenkins-job-builder or a reverse proxy.
2015-12-23 11:38:57 +01:00