Mirroring Git/GitHub to Hg/BitBucket

This seemed a lot longer when I planned it in my notebook at lunch.

GitHub user project (both sides) BitBucket user SCM Schedule
ocornut imgui g-pechorin None Periodic
  1. Install hg-git
    • You’ll have to do this on the Jenkins server
    • You’ll have to do it either for the Jenkins user or all
    • I’m using an OsX machine as my host, so I was able to use easy_install to install hg-git and dulwich
  2. setup a project on GitHub
  3. create a Jenkins Freestyle project which runs periodically
    • Polling the SCM was NOT an option since there’s no default branch on GitHub
      • … this is a quirk of hg-git … I think
      • … IIRC/YRMV - so sling me a tweet or whatever if I’m wrong
  4. program the job to pull from git, push to hg, and ignore results of 1

    • this was only elaborate because I needed it to not fail when there were no changes

      #!/bin/bash
      
      if [ -d "imgui" ]; then
          echo "Re-Using ImGUI"
          cd imgui
          hg pull git+ssh://git@github.com:ocornut/imgui.git
      else
          echo "Cloning ImGUI"
          hg clone git+ssh://git@github.com:ocornut/imgui.git
          cd imgui
      fi
      
      hg push -f ssh://hg@bitbucket.org/g-pechorin/imgui
      
      retcode=$?
      
      if [ $retcode -eq 0 ] || [ $retcode -eq 1 ]; then
          exit 0
      else
          exit $retcode
      fi
      
comments powered by Disqus
Peter LaValle avatar
Peter LaValle
Any links probably include affiliate ids for that sweet sweet kickback - and some programs require that I tell you. The contents of this blog are likely unrelated - as they include games, paints, and build tools.