Skip to content

Commit

Permalink
#6 wait until Jenkins has started
Browse files Browse the repository at this point in the history
- then download Jenkins CLI JAR
- then run CLI to perform first build and deployment of petclinic war
- note: does not work due to JENKINS-25858. This is WIP so currently commented the offending lines.
  • Loading branch information
savishy committed Aug 3, 2016
1 parent 46db4ef commit 2359a19
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 1 addition & 2 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: setup docker and run Dockerfile
- name: setup docker and run Dockerfiles

# name of the host to run this on.
hosts: default
Expand All @@ -11,7 +11,6 @@
ansible_become: true

roles:
# Only one role: Docker
- install_docker
- docker_jenkins
- docker_tomcat
Expand Down
34 changes: 33 additions & 1 deletion roles/docker_jenkins/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- name: build jenkins docker image if needed
command: docker build -t jenkins-builder /vagrant/dockerfiles/jenkins-ci/
command: docker build -t jenkins-ci /vagrant/dockerfiles/jenkins-ci/

# run docker jenkins container
# TODO running this as root. see dockerfile
# NOTE: force_kill: true means existing containers will be forcibly stopped
- name: run jenkins docker container
docker_container:
name: jenkins-ci-container
Expand All @@ -13,5 +14,36 @@
exposed: 8081
recreate: true
user: root
detach: true

# wait until Jenkins has started
# http://stackoverflow.com/a/23957310/682912
- name: Wait untils Jenkins web API is available
shell: curl --head --silent http://localhost:8081/cli/
register: result
until: result.stdout.find("200 OK") != -1
retries: 10
delay: 5

# get Jenkins CLI JAR
- name: download Jenkins CLI Jar
command: wget http://localhost:8081/jnlpJars/jenkins-cli.jar
args:
chdir: /vagrant/dockerfiles/jenkins-ci/
creates: /vagrant/dockerfiles/jenkins-ci/jenkins-cli.jar


# TODO this does not work
# modify eth0 to allow building with Jenkins CLI without encountering the
# error "unexpected termination of channel"
# https://issues.jenkins-ci.org/browse/JENKINS-25858
# https://github.com/scala/scala-jenkins-infra/issues/26#issuecomment-73825006


# - name: modify eth0 to allow Jenkins CLI
# command: ethtool -K eth0 sg off

# - name: initiate first build of petclinic
# command: java -jar jenkins-cli.jar -s http://localhost:8081 build petclinic-build -v -s
# args:
# chdir: /vagrant/dockerfiles/jenkins-ci/

0 comments on commit 2359a19

Please sign in to comment.