Deployment Using Jenkins flaky and learning points

The Deployment Using Jenkins task is flaky:

  • sometimes the gitea webhook exists, and sometimes you have to create it; I’m all for variants on tasks BUT having to create it is a major increase in difficulty level, as the webhook is not documented in gitea or jenkins, it must be discovered from plugin source or from stackoverfloa
  • sometimes the /data folder on ststor01 is rwx by all, sometimes it is writable only by root. When the latter, this prevents using a remote directory in the Publish via SSH plugin config, so the job configuration gets more complicated AND requires sudo which requires using password in cleartext which IS A BAD PRACICE

Here are some learning points that I got out of this task (even though I’ve been using jenkins and git for several years!):

  • In ststor01,
    • enable natasha to write to /data and create subdirectories in it; the task description is clear that you have to copy all files not just index.html. There are many ways to do this but simplest and fastest is to ssh natasha@ststor01, then sudo su -, then chown -R natasha /data
  • In Jenkins,
    • install not only the gitea and publish ssh plugins, but also the SSH Credentials plugin, as it makes it really easy to create sarah creds anywhere and re-use anywhere in jenkins
    • you do NOT need an alias for the web hook defined in gitea plugin
    • select Poll SCM for the trigger, without a schedule. From this page, this is because empty schedule means the SCM will be polled only when triggered by a post-commit event. I could not find this documented in Jenkins, if anyone knows please post.
    • you only need one build step, Send files over SSH, with ** as file filter otherwise you will not get subfolders copied to destination.
  • In Gitea,
    • When creating a webhook for sarah in gitea, the URL for jenkins webhook is not obvious to find: it is JENKINS_HOST/gitea-webhook/post.
    • You do not need any query parameter after this URL, they are just ignored; some posts indicate you need job name but this is in fact ignored (you can put any job name even does not exist and the proper job will work in jenkins – this is because gitea provides payload with the webhook, and this payload says which git repo has event, and that’s enough for gitea plugin in jenkins to know what to do)