blob: a00c87a607551764708d26128c75468c81bdeacf [file] [log] [blame]
---
# jenkins molecule/default/verify.yml
#
# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
- name: Verify
hosts: all
vars:
jenkins_localhost: "127.0.0.1:8080"
jenkins_admin_username: "admin"
jenkins_admin_password: "change_me"
jenkins_job_builder_conf: "/tmp/jenkins.conf"
jenkins_plugins:
- name: ec2
- name: crowd2
- name: docker-workflow
- name: gerrit-trigger
- name: workflow-aggregator
tasks:
- name: Check Jenkins instance accessibility
uri:
url: "http://{{ jenkins_localhost }}/cli/"
method: GET
return_content: "yes"
timeout: 5
body_format: raw
follow_redirects: "no"
status_code: 200,403
register: result
until: (result.status == 403 or result.status == 200)
and (result.content.find("Please wait while") == -1)
retries: 60
delay: 5
- name: Install pip
apt:
name: python3-pip
- name: Install jenkins job builder
pip:
name: jenkins-job-builder
- name: Create file with Jenkins conf for JJB
copy:
dest: "{{ jenkins_job_builder_conf }}"
mode: 0400
content: |
[jenkins]
user={{ jenkins_admin_username }}
password={{ jenkins_admin_password }}
url=http://localhost:8080
- name: List jobs via JJB tools
command: "jenkins-jobs --conf {{ jenkins_job_builder_conf }} list"
register: jobs_contents
changed_when: false
- name: Assert we are able to access Jenkins with admin username and password.
assert:
that:
- "'INFO:root:Matching jobs: 0' in jobs_contents.stderr"
- name: Save installed plugins to plugins_info.yaml
command: "jenkins-jobs --conf {{ jenkins_job_builder_conf }} get-plugins-info"
changed_when: false
- name: read the plugin_info file
shell: cat plugins_info.yaml
register: plugins_contents
- name: Assert Jenkins install all required plugins
assert:
that:
- "' shortName: {{ item.name }}' in plugins_contents.stdout_lines"
with_items: "{{ jenkins_plugins }}"