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