blob: f6d52ab3ad20dcd68730f26779baa7253d234942 [file] [log] [blame]
Ian Wienand7bb5fff2018-12-19 14:16:41 +11001- name: Find all OpenStack source repos used by this job
Monty Taylor36ddea32017-10-02 10:05:17 -05002 find:
3 paths:
OpenDev Sysadmins666f5492019-04-19 19:43:10 +00004 - src/opendev.org/openstack
5 - src/opendev.org/openstack-dev
6 - src/opendev.org/openstack-infra
Monty Taylor36ddea32017-10-02 10:05:17 -05007 file_type: directory
8 register: found_repos
9
10- name: Copy Zuul repos into devstack working directory
11 command: rsync -a {{ item.path }} {{ devstack_base_dir }}
12 with_items: '{{ found_repos.files }}'
13 become: yes
14
Ian Wienand7bb5fff2018-12-19 14:16:41 +110015# Github projects are github.com/username/repo (username might be a
16# top-level project too), so we have to do a two-step swizzle to just
17# get the full repo path (ansible's find module doesn't help with this
18# :/)
19- name: Find top level github projects
20 find:
21 paths:
22 - src/github.com
23 file_type: directory
24 register: found_github_projects
25
26- name: Find actual github repos
27 find:
28 paths: '{{ found_github_projects.files | map(attribute="path") | list }}'
29 file_type: directory
30 register: found_github_repos
31 when: found_github_projects.files
32
33- name: Copy github repos into devstack working directory
34 command: rsync -a {{ item.path }} {{ devstack_base_dir }}
35 with_items: '{{ found_github_repos.files }}'
36 become: yes
37 when: found_github_projects.files
38
Andrea Frittoli14738842018-09-13 17:50:29 +020039- name: Setup refspec for repos into devstack working directory
40 shell:
41 # Copied almost "as-is" from devstack-gate setup-workspace function
42 # but removing the dependency on functions.sh
43 # TODO this should be rewritten as a python module.
44 cmd: |
45 cd {{ devstack_base_dir }}/{{ item.path | basename }}
46 base_branch={{ devstack_sources_branch }}
47 if git branch -a | grep "$base_branch" > /dev/null ; then
48 git checkout $base_branch
49 elif [[ "$base_branch" == stable/* ]]; then
50 # Look for an eol tag for the stable branch.
51 eol_tag=${base_branch#stable/}-eol
52 if git tag -l |grep $eol_tag >/dev/null; then
53 git checkout $eol_tag
54 git reset --hard $eol_tag
55 if ! git clean -x -f -d -q ; then
56 sleep 1
57 git clean -x -f -d -q
58 fi
59 fi
60 else
61 git checkout master
62 fi
63 args:
64 executable: /bin/bash
65 with_items: '{{ found_repos.files }}'
66 when: devstack_sources_branch is defined
67
Monty Taylor36ddea32017-10-02 10:05:17 -050068- name: Set ownership of repos
69 file:
70 path: '{{ devstack_base_dir }}'
71 state: directory
72 recurse: true
73 owner: stack
74 group: stack
75 become: yes