[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[all] New Zuul job to replicate a project's git repository to a remote git server


It is now possible for projects to replicate their git repository to a
custom location by inheriting from the 'upload-git-mirror' job
provided by Zuul.
This job wraps around the 'upload-git-mirror' Ansible role that is
part of the zuul-jobs library [1].

In order to use this job, you must supply a secret in the following format:
- secret:
    name: <name of your secret>
      user: <ssh user of the remote git server>
      host: <address of the remote git server>
      host_key: <ssh host key of the remote git server>
      ssh_key: <private key to authenticate with the remote git server>

The 'host_key' parameter can be retrieved from your known_hosts file
or with a command like 'ssh-keyscan -H <host>' or 'ssh-keyscan -t rsa
For example, the 'host_key' when pushing to GitHub would be, on a single line: ssh-rsa

The 'ssh_key' parameter should be encrypted before being committed to
the git repository.
Zuul provides a tool for easily encrypting files such as SSH private
keys and you can find more information about it in the documentation

For example, encrypting a key for the "openstack/ara" project would
look like this:
zuul/tools/ --infile /home/dmsimard/.ssh/ara_git_key
--tenant openstack openstack/ara

You would then use the secret in a job inheriting from
'upload-git-mirror' as such:
- job:
    name: <project>-upload-git-mirror
    parent: upload-git-mirror
    description: Mirrors openstack/<project> to neworg/<project>
      git_mirror_repository: neworg/<project>
      - name: git_mirror_credentials
        secret: <name of your secret>
        pass-to-parent: true

Finally, the job must be set to run in your project's 'post' pipeline
which is triggered every time a new commit is merged to the
- project:
        # [...]
        # [...]
        - <project>-upload-git-mirror

Note that the replication would only begin *after* the change has
merged, meaning that merging the addition of the post job would not
trigger the post job itself immediately.
The post job will only trigger the next time that a commit is merged.


David Moreau Simard
dmsimard = [irc, github, twitter]