| --- |
| - name: Create and update repositories in BitBucket |
| hosts: localhost |
| connection: local |
| vars_files: |
| - workspace-github-repos.yml |
| - workspace-folders.yml |
| - bitbucket-repo-user-list.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 |
| uri: |
| url: "{{ bitbucket_project_api_endpoint }}/permissions/users?name={{ item }}&permission=PROJECT_ADMIN" |
| method: PUT |
| user: "{{ vz_windows_user }}" |
| password: "{{ vz_windows_password }}" |
| force_basic_auth: yes |
| status_code: 204,409 |
| with_items: "{{ repo_users }}" |
| |
| - 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 }}" |