blob: e53e386b254514f4b04b52517b6a008e520931a0 [file] [log] [blame]
---
- name: Create repositories in BitBucket
hosts: localhost
connection: local
vars_files:
- workspace-github-repos.yml
- workspace-folders.yml
- bitbucket-users.yml
vars:
bitbucket_project_api_endpoint: "https://onestash.verizon.com/rest/api/1.0/projects/CELVW"
bitbucket_repo_api_endpoint: "{{ bitbucket_project_api_endpoint }}/repos"
tasks:
- name: Create repositories if necessary
uri:
url: "{{ bitbucket_repo_api_endpoint }}"
method: POST
user: "{{ vz_windows_user }}"
password: "{{ vz_windows_password }}"
force_basic_auth: yes
status_code: 201,409
body_format: json
body:
name: "{{ item.repo_name }}"
scmId: git
forkable: True
with_items: "{{ repo_names }}"
- name: Add permissions to repos
include: bitbucket-add-user-permission.yml
with_items: "{{ repo_users }}"
loop_control:
loop_var: repo_user
- name: Add Onestash as remote repo
ignore_errors: true
shell: "git remote add vz ssh://git@onestash.verizon.com:7999/celvw/{{ item.repo_name }}.git"
args:
chdir: "{{ item.workspace }}/{{ item.repo_name }}"
with_items: "{{ repo_names }}"
- name: Commit updated repos to onestash
shell: "git checkout master && git push -u vz master"
args:
chdir: "{{ item.workspace }}/{{ item.repo_name }}"
with_items: "{{ repo_names }}"