Clark Boylan f41d9da163 Handle launchpad projects in our gitea project creation
Some projects use storyboard and some use launchpad as their issue
tracker. Handle this dynamically based on the projects.yaml content when
we create projects and set the appropriate urls.

Change-Id: Ie1d79bf1a662c00078689f2c752231e610610eda
Story: 2004627
Task: 29849
2019-03-12 15:14:34 -07:00

91 lines
3.4 KiB
YAML

- name: debug
debug:
msg: "{{ project }}"
- name: Parse project name
set_fact:
org: "{{ project.project | regex_replace('^(.*)/(.*)$', '\\1') }}"
repo: "{{ project.project | regex_replace('^(.*)/(.*)$', '\\2') }}"
- name: Create repo
when: project.project not in gitea_repos
uri:
url: "{{ gitea_url }}/api/v1/org/{{ org }}/repos"
user: root
password: "{{ gitea_root_password }}"
force_basic_auth: true
validate_certs: false
status_code: 201
method: POST
body_format: json
body:
auto_init: true
description: "{{ (project.description | default(''))[:255] }}"
name: "{{ repo }}"
private: false
readme: Default
register: create_repo_result
- name: Set storyboard tracker url
when: "'use-storyboard' in project and project['use-storyboard']"
set_fact:
external_tracker_url: "https://storyboard.openstack.org/#!/project/{{ org }}/{{ repo }}"
- name: Set storyboard tracker url format
when: "'use-storyboard' in project and project['use-storyboard']"
set_fact:
tracker_url_format: "https://storyboard.openstack.org/#!/story/{index}"
- name: Set launchpad tracker url
when: "('use-storyboard' not in project or not project['use-storyboard']) and ('groups' not in project or not project['groups'])"
set_fact:
external_tracker_url: "https://bugs.launchpad.net/{{ repo }}"
- name: Set launchpad tracker url format
when: "('use-storyboard' not in project or not project['use-storyboard']) and ('groups' not in project or not project['groups'])"
set_fact:
tracker_url_format: "https://bugs.launchpad.net/{{ repo }}/+bug/{index}"
- name: Set launchpad tracker url if group set
when: "('use-storyboard' not in project or not project['use-storyboard']) and ('groups' in project and project['groups'])"
set_fact:
external_tracker_url: "https://bugs.launchpad.net/{{ project.groups[0] }}"
- name: Set launchpad tracker url format if group set
when: "('use-storyboard' not in project or not project['use-storyboard']) and ('groups' in project and project['groups'])"
set_fact:
tracker_url_format: "https://bugs.launchpad.net/{{ project.groups[0] }}/+bug/{index}"
- name: Adjust repo settings
when: gitea_always_update or project.project not in gitea_repos
uri:
url: "{{ gitea_url }}/{{ org }}/{{ repo }}/settings"
validate_certs: false
user: root
password: "{{ gitea_root_password }}"
force_basic_auth: true
status_code: 302
method: POST
body_format: form-urlencoded
body:
_csrf: "{{ gitea_token }}"
action: advanced
# enable_pulls is not provided, which disables it
# enable_wiki is not provided, which disables it
enable_external_wiki: false
external_wiki_url:
# enable_issues is on so that issue links work
enable_issues: on
enable_external_tracker: true
external_tracker_url: "{{ external_tracker_url }}"
tracker_url_format: "{{ tracker_url_format }}"
tracker_issue_style: numeric
- name: Set default branch
when: gitea_always_update or project.project not in gitea_repos
uri:
url: "{{ gitea_url }}/{{ org }}/{{ repo }}/settings/branches"
validate_certs: false
user: root
password: "{{ gitea_root_password }}"
force_basic_auth: true
status_code: 302
method: POST
body_format: form-urlencoded
body:
_csrf: "{{ gitea_token }}"
action: default_branch
branch: master