Add API to find job schedules

XMLWordPrintable

    • 0
    • 2

      Issue Description

      Currently, there is no way to retrieve schedules (cron expressions) using a REST API. We can use the Admin REST API /rest/admin/latest/scheduler/jobs endpoint to get the next scheduled run, but not the configuration.

      Suggestions

      • Expand the Admin API endpoint to add /rest/admin/latest/scheduler/jobs with the cron (or prettified cron) expression
      • Add an expand parameter to include the cron
      • Add cron expression to /rest/admin/latest/scheduler/jobs endpoint

      Workaround

      The details can be retrieved from the database and filesystem. For example:

      Database

      SQL queries below use PostgreSQL syntax. XML expressions may use different functions depending on the database type.

      Builds
      select b.full_key, 
      unnest(xpath('//triggers/triggerDefinition', bd.xml_definition_data::xml)) 
      from build b 
      join  build_definition bd 
        on (b.build_id = bd.build_id) 
      where b.build_type in ('CHAIN', 'CHAIN_BRANCH');
      

      There are more queries to get specific trigger types linked to the following article. The article shows 5.x versions, but I can confirm that the queries work up to and including the current version (7.2.3).

      Deployments
      select dp.name, 
      de.name, 
      unnest(xpath('//triggerDefinition/pluginKey[text()="com.atlassian.bamboo.triggers.atlassian-bamboo-triggers:schedule"]/../config/item/key[text()="repository.change.schedule.cronExpression"]/../value/text()', triggers_xml_data::xml)) as schedule 
      from deployment_project dp 
      join deployment_environment de 
        on (dp.deployment_project_id = de.package_definition_id);
      

      administration.xml

      Expiry

      The Expiry schedule is defined in the following file:

      <bamboo-home>/xml-data/configuration/administration.xml

      You can retrieve the cron schedule with the following:

      # may need to install `xmllint` to your server
      # apt-get install libxml2-utils
      xmllint --xpath '//myBuildExpiryConfiguration/cronExpression/text()' <bamboo-home>/xml-data/configuration/administration.xml
      
      Branch detection

      The Branch Detection interval is also defined in administration.xml.
      You can retrieve the interval, in seconds, with the following:

      xmllint --xpath '//branchDetectionCheckInterval/text()' <bamboo-home>/xml-data/configuration/administration.xml
      

            Assignee:
            Unassigned
            Reporter:
            Ellie Z
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: