Hung-Wei Chiu | 80dc18d | 2020-10-20 23:56:46 +0000 | [diff] [blame] | 1 | --- |
| 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 Chiu | 72e8f60 | 2020-11-06 22:02:09 +0000 | [diff] [blame] | 12 | jenkins_admin_password: "change_me" |
Hung-Wei Chiu | 80dc18d | 2020-10-20 23:56:46 +0000 | [diff] [blame] | 13 | jenkins_job_builder_conf: "/tmp/jenkins.conf" |
Hung-Wei Chiu | 72e8f60 | 2020-11-06 22:02:09 +0000 | [diff] [blame] | 14 | jenkins_plugins: |
| 15 | - name: ec2 |
| 16 | - name: crowd2 |
| 17 | - name: docker-workflow |
| 18 | - name: gerrit-trigger |
| 19 | - name: workflow-aggregator |
Hung-Wei Chiu | 80dc18d | 2020-10-20 23:56:46 +0000 | [diff] [blame] | 20 | 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 Chiu | 72e8f60 | 2020-11-06 22:02:09 +0000 | [diff] [blame] | 53 | register: jobs_contents |
Hung-Wei Chiu | 80dc18d | 2020-10-20 23:56:46 +0000 | [diff] [blame] | 54 | changed_when: false |
| 55 | |
| 56 | - name: Assert we are able to access Jenkins with admin username and password. |
| 57 | assert: |
| 58 | that: |
Hung-Wei Chiu | 72e8f60 | 2020-11-06 22:02:09 +0000 | [diff] [blame] | 59 | - "'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 }}" |