Main question is: how do you know that Jenkins task will be started and ended? And who will execute the maintenance commands?
Because UIM has several ways to interact with the maintenance_mode.
All will pass via UIMAPI call (or Rest services if you are on older versions)
You can call them via curl, Perl, Java, (and other supported languages)
If you want to use a pre-coded Perl sample you can have a look at:
- nimsoft_rest_maintenance (for the moment with rest services, but uimapi will be posted soon): set/unset maintenance via perl command line (https://community.broadcom.com/enterprisesoftware/communities/community-home/digestviewer/viewthread?MessageKey=6e99bfe5-0543-45f3-bd6e-33a1f11c825b)
- maint_on probe: set/unset maintenance via Nimalarm that will be trapped and performed by the probe (here also: for the moment with rest services, but new version with uimapi is in tested) (https://community.broadcom.com/enterprisesoftware/communities/community-home/digestviewer/viewthread?MessageKey=81bfccc5-5d27-4fb3-a1a2-2e745f41e1cc)