blob: a00c87a607551764708d26128c75468c81bdeacf [file] [log] [blame]
Hung-Wei Chiu80dc18d2020-10-20 23:56:46 +00001---
2# jenkins molecule/default/verify.yml
3#
4# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
5# SPDX-License-Identifier: Apache-2.0
6
7- name: Verify
8 hosts: all
9 vars:
10 jenkins_localhost: "127.0.0.1:8080"
11 jenkins_admin_username: "admin"
Hung-Wei Chiu72e8f602020-11-06 22:02:09 +000012 jenkins_admin_password: "change_me"
Hung-Wei Chiu80dc18d2020-10-20 23:56:46 +000013 jenkins_job_builder_conf: "/tmp/jenkins.conf"
Hung-Wei Chiu72e8f602020-11-06 22:02:09 +000014 jenkins_plugins:
15 - name: ec2
16 - name: crowd2
17 - name: docker-workflow
18 - name: gerrit-trigger
19 - name: workflow-aggregator
Hung-Wei Chiu80dc18d2020-10-20 23:56:46 +000020 tasks:
21 - name: Check Jenkins instance accessibility
22 uri:
23 url: "http://{{ jenkins_localhost }}/cli/"
24 method: GET
25 return_content: "yes"
26 timeout: 5
27 body_format: raw
28 follow_redirects: "no"
29 status_code: 200,403
30 register: result
31 until: (result.status == 403 or result.status == 200)
32 and (result.content.find("Please wait while") == -1)
33 retries: 60
34 delay: 5
35 - name: Install pip
36 apt:
37 name: python3-pip
38 - name: Install jenkins job builder
39 pip:
40 name: jenkins-job-builder
41 - name: Create file with Jenkins conf for JJB
42 copy:
43 dest: "{{ jenkins_job_builder_conf }}"
44 mode: 0400
45 content: |
46 [jenkins]
47 user={{ jenkins_admin_username }}
48 password={{ jenkins_admin_password }}
49 url=http://localhost:8080
50
51 - name: List jobs via JJB tools
52 command: "jenkins-jobs --conf {{ jenkins_job_builder_conf }} list"
Hung-Wei Chiu72e8f602020-11-06 22:02:09 +000053 register: jobs_contents
Hung-Wei Chiu80dc18d2020-10-20 23:56:46 +000054 changed_when: false
55
56 - name: Assert we are able to access Jenkins with admin username and password.
57 assert:
58 that:
Hung-Wei Chiu72e8f602020-11-06 22:02:09 +000059 - "'INFO:root:Matching jobs: 0' in jobs_contents.stderr"
60
61 - name: Save installed plugins to plugins_info.yaml
62 command: "jenkins-jobs --conf {{ jenkins_job_builder_conf }} get-plugins-info"
63 changed_when: false
64
65 - name: read the plugin_info file
66 shell: cat plugins_info.yaml
67 register: plugins_contents
68
69 - name: Assert Jenkins install all required plugins
70 assert:
71 that:
72 - "' shortName: {{ item.name }}' in plugins_contents.stdout_lines"
73 with_items: "{{ jenkins_plugins }}"