Run some tasks as jenkins user so that the permissions are correct. Also some refactoring of the jenkins tasks.