summaryrefslogtreecommitdiff
path: root/playbooks/tutorial/quick-start.yaml
blob: 872b0e689fbc8dc49016cfc21b6c43f9cc57c8f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
- name: Init Test1
  include_role:
    name: init-repository
  vars:
    projectname: test1

- name: Copy data to test1
  copy:
    src: ../../doc/source/examples/test1/
    dest: "{{ workspace }}/test1/"

- name: Commit and upload test change in test1
  shell:
    chdir: "{{ workspace }}/test1/"
    executable: /bin/bash
    cmd: |
      {{ ssh_agent.stdout }}
      mv zuul.yaml .zuul.yaml
      git add .zuul.yaml playbooks
      git commit -m "Add test Zuul job"
      git review

- import_role:
    name: check-pipeline
  vars:
    title: "test job test1"
    projectname: test1

- name: Save test1 change info
  set_fact:
    changetest1: "{{ changeinfo }}"
    json_query_finger: "messages[?contains(@.message, 'testjob http://')].message | [0]"

- name: "Check build URL"
  assert:
    that:
      - (result_json | to_json | from_json | json_query(json_query_finger) | regex_search('(http://[^ ]*)') | length > 0)

- name: Configure a Base Job zuul-config
  copy:
    src: ../../doc/source/examples/zuul-config/playbooks/base/
    dest: "{{ workspace }}/zuul-config/playbooks/base/"

- name: Update the base job definition
  copy:
    src: ../../doc/source/examples/zuul-config/zuul.d/jobs2.yaml
    dest: "{{ workspace }}/zuul-config/zuul.d/jobs.yaml"

- name: Commit and upload zuul-config
  shell:
    chdir: "{{ workspace }}/zuul-config/"
    executable: /bin/bash
    warn: false
    cmd: |
      {{ ssh_agent.stdout }}
      git add playbooks zuul.d/jobs.yaml
      git commit -m "Update Zuul base job"
      git review

- include_role:
    name: change-merged
  vars:
    title: "Update Zuul base job"
    projectname: zuul-config

# Remove the label so Zuul will post again Verified+1 which is what
# check-pipeline is looking for
- include_role:
    name: remove-verified
  vars:
    change_id: "{{ changetest1.id }}"

- include_role:
    name: recheck-change
  vars:
    change_id: "{{ changetest1.id }}"

- include_role:
    name: check-pipeline
  vars:
    title: "test job test1"
    projectname: test1
    check_number: 2

- name: Find the build URL with regex
  set_fact:
    build_url: "{{ result_json | to_json | from_json | json_query(json_query_log_url) | regex_search('-.*(http://[^ ]*)') | regex_search('(http://[^ ]*)') }}"
  vars:
    json_query_log_url: "messages[?contains(@.message, 'http://')].message | [1]"

- name: Extract build id from build url
  set_fact:
    build_uuid: "{{ build_url.split('/')[-1] }}"

- name: Find log URL via Zuul API
  uri:
    url: "http://localhost:9000/api/tenant/example-tenant/build/{{ build_uuid }}"
    method: GET
    return_content: true
  register: result

- name: Fetch log URL
  get_url:
    url: "{{ result.json.log_url }}job-output.txt"
    dest: "{{ workspace }}/job-output.txt"

- name: Verify log contents
  command: "grep 'Hello world!' {{ workspace }}/job-output.txt"