Blob Blame History Raw
- name: Check if {{ project }} project exists
  uri:
    url: http://localhost:8081/projects/{{ project }}
    status_code: 200, 404
  register: project_check
- name: Create {{ project }}
  when: project_check.status==404
  block:
    - name: Create temp dir for {{ project }} creation
      shell: mktemp -d
      register: project_tmp
    - name: Create {{ project }} project in Gerrit
      uri:
        url: http://localhost:8081/a/projects/{{ project }}
        method: PUT
        user: admin
        password: secret
        status_code: 201
    - name: Initialize .gitreview
      shell:
        executable: /bin/sh
        chdir: "{{ project_tmp.stdout }}"
        cmd: |
          git init .
          git config user.name "Admin"
          git config user.email "admin@example.com"
          cat >.gitreview <<EOF
          [gerrit]
          host=gerrit
          project={{ project }}
          EOF
    - name: Create .zuul.yaml
      copy:
        src: zuul.yaml
        dest: "{{ project_tmp.stdout }}/.zuul.yaml"

    - name: Create my-noop.yaml
      copy:
        src: my-noop.yaml
        dest: "{{ project_tmp.stdout }}/my-noop.yaml"

          git add .gitreview
          git commit -m "Initial commit"
          git remote add gerrit http://admin:secret@localhost:8081/{{ project }}
          git push -f --set-upstream gerrit +HEAD:master