Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-21300

Add API to find job schedules

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • REST API
    • None
    • 0
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      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
      

              Unassigned Unassigned
              ezeidan Ellie Z (they/them)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: