Gitea On MiniShift - ocd-scm/ocd-meta GitHub Wiki

To test git OCD webhooks on Minishift you can use a Gitea server:

Gitea is a painless self-hosted Git service. It is similar to GitHub, Bitbucket, and Gitlab. Gitea is a fork of Gogs. See the Gitea Announcement blog post to read about the justification for a fork.

We can install it along with a postgres database to store its documents using the approach at https://github.com/wkulhanek/docker-openshift-gitea i.e.,

# make sure we are not setting up only as admin use a regular user
oc logout
oc login -u developer -p password
# [OPTIONAL] install into its own project
oc new-project gitea
# compute the minishift nip.io url that will point to your local minishift
PROJECT=$(oc project --short)
MINISHIFT_IP=$(oc project | sed 's/.*\/\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/g')
GITEA_URL="gitea-${PROJECT}.${MINISHIFT_IP}.nip.io"
# run the template setting the route to the current local url
oc new-app -f https://raw.githubusercontent.com/wkulhanek/docker-openshift-gitea/master/openshift/gitea-persistent-template.yaml --param=HOSTNAME=${GITEA_URL} --param=GITEA_VERSION=1.9.2 --param=GITEA_IMAGE=docker.io/simonmassey/gitea
# note it takes a while for postgres to be ready so the gitea pod will crash a few times

Note it may take a while for things to install and postgres to start. You can try to open it up with:

open http://$GITEA_URL

That code guesses the correct HOSTNAME as something like gitea-ocd-builder.192.168.99.100.nip.io/ which includes your local minishift IP address which may be wrong. If it guesses wrong simply run:

oc delete route/gitea
oc expose svc gitea
oc get routes

That will recreate and print out the correct default route URL that you can open. Currently, things open fine in Safari but as the minishift web console doesn't safari I tend to use Chrome.

The first thing you should do is register to create a login then import the demo code into it ready to setup some git webhooks to fire at OCD.

If your locally testing Gitea on Minishift you probably want to use a "personal access token" which is a random GUI rather than an ssh key for your git url for push access. You create one on this screen:

gitea personal access tokens

It only shows you the random UUID token once upon creation then never again. Then you use it as an identity within the HTTP URL of the repo you checkout e.g.

$ git remote show minishift
* remote minishift
  Fetch URL: http://ffdbaa5f8689920e9389ad321760a65f0ead6d91@gitea-gitea.192.168.99.100.nip.io/simbo1905/env-build.git
  Push  URL: http://ffdbaa5f8689920e9389ad321760a65f0ead6d91@gitea-gitea.192.168.99.100.nip.io/simbo1905/env-build.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

Then you can git push minishift master local changes into Minishift to test your configuration.

Note: you can retrofit a token to your gitea or github.com local checkouts with git remote set-url origin $URL.