Skip to content

Commit

Permalink
Add parameter to copy custom init.d scripts. Closes #151.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianludwig committed Sep 8, 2017
1 parent 4c63ef2 commit e364a3a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Expand Up @@ -64,6 +64,12 @@ env:
prefix: ''
http_port: 8080

# tests/test-plugins-with-pinning.yml
- distro: ubuntu1604
playbook: test-initd-scripts.yml
prefix: ''
http_port: 8080

script:
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -109,6 +109,10 @@ Extra Java options for the Jenkins launch command configured in the init file ca

Changes made to the Jenkins init script; the default set of changes set the configured URL prefix and add in configured Java options for Jenkins' startup. You can add other option/value pairs if you need to set other options for the Jenkins init file.

jenkins_initd_files: []

List of files that will be copied to [Jenkins' `init.d` directory](https://wiki.jenkins.io/display/JENKINS/Post-initialization+script) to configure Jenkins during startup.

## Dependencies

- geerlingguy.java
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Expand Up @@ -30,6 +30,8 @@ jenkins_admin_token_file: ""
jenkins_process_user: jenkins
jenkins_process_group: "{{ jenkins_process_user }}"

jenkins_initd_files: []

jenkins_init_changes:
- option: "JENKINS_ARGS"
value: "--prefix={{ jenkins_url_prefix }}"
Expand Down
9 changes: 9 additions & 0 deletions tasks/main.yml
Expand Up @@ -28,6 +28,15 @@
# Configure Jenkins init settings.
- include: settings.yml

- name: Copy init.d scripts
copy:
src: "{{ item }}"
dest: "{{ jenkins_home }}/init.groovy.d/"
owner: "{{ jenkins_process_user }}"
group: "{{ jenkins_process_group }}"
mode: 0664
with_items: "{{ jenkins_initd_files }}"

# Make sure Jenkins starts, then configure Jenkins.
- name: Ensure Jenkins is started and runs on startup.
service: name=jenkins state=started enabled=yes
Expand Down
4 changes: 4 additions & 0 deletions tests/initd_test.groovy
@@ -0,0 +1,4 @@
import jenkins.model.*;

// start in the state that doesn't do any build.
Jenkins.instance.doQuietDown();
13 changes: 13 additions & 0 deletions tests/test-initd-scripts.yml
@@ -0,0 +1,13 @@
---
- hosts: all

vars:
jenkins_initd_files:
- "{{ role_path }}/tests/initd_test.groovy"

pre_tasks:
- include: java-8.yml

roles:
- geerlingguy.java
- role_under_test

0 comments on commit e364a3a

Please sign in to comment.