Call refreshjobs action script when doing initial jenkins job import
Eliminates duplicate code, and also allows the mkjobs hook to be called
during initial import. It will cause a git pull to happen right after
the initial clone - likely a no-op, but adds a bit of overhead.
Now that we've a suitable (and working!) replacement in place, get rid
of the @when_file_changed trigger.
Existing Scalebot config repos with jobs that make use of this trigger
will need to be updated. Though, AFAICT, those jobs don't work today
anyway. I tried watching juju debug-log while making changes to the
/var/lib/jenkins/updatejobs file, but I didn't see anything happen.
Make 'refreshjobs' action just a small wrapper around pull-and-reload-jobs
Instead of relying on the @when_file_changed('/var/lib/jenkins/updatejobs')
hack, lets make the action synchronous by having it run pull-and-reload-jobs
directly.
Now that
- The git config contains everything we need to do a pull
- The necessary commands are in a predictable place
- The jobset is available outside of charm context
We can create a simple shell script to refresh git and update jobs.
Make jobsync.py available to jenkins user in predictable path
We want a jenkins jobs to be able to update jobs directly, so we need
the jenkins user to be able to find the jobsync.py script. In charm
context, we know it lives under $JUJU_CHARM_DIR, but $JUJU_CHARM_DIR
isn't set outside of charm context. So, let's put move jobsync.py
into a "bin" directory in the charm and symlink that into
$SCALEBOT_HOME, which is now exported system-wide.
In a later commit the charm will start making some tools available under
$SCALEBOT_HOME so that non-charm users can find them. Export SCALEBOT_HOME
so that these non-charm users (e.g. jenkins jobs) know where that is.
For non-charm job syncs, we need to expose which jobset was selected
in the charm config. Since this variable needs to change with the config,
rewrite the variables file whenever config-changed. Also, remove obvious
comment instead of trying to keep it up to date.
Assigning each line to a variable before writing it out doesn't make
it any more readable, and it makes it uglier as we add more variables.
Formulate the lines at the same time we write them out.
Change ownership of repository from ubuntu to jenkins
We want to allow a jenkins job to update the git repo directly, so that
a jenkins job can refresh the repo/update jobs. Jobs can not do this today
because the repo is owned by user ubuntu, but the jobs run as user jenkins.