connected-web / product-monitor

A HTML/JavaScript template for monitoring a product by encouraging product developers to gather all the information about the status of a product, including live monitoring, statistics, endpoints, and test results into one place.
8 stars 3 forks source link

Ability to check the status of Jenkins jobs #20

Open Markavian opened 9 years ago

Markavian commented 9 years ago

Feature: write a component tag that lets you hook into a Jekins job, or jobs, with an appropriate filter.

e.g.:

<jenkins-job-status data-url="" job-name="">Custom Label</jenkins-job-status>

e.g. data source:

{
    assignedLabels: [
        {

        }
    ],
    mode: "EXCLUSIVE",
    nodeDescription: "the master Jenkins node",
    nodeName: "",
    numExecutors: 2,
    description: null,
    jobs: [
        {
            name: "config-provider-model",
            url: "http://ci.jenkins-ci.org/job/config-provider-model/",
            color: "blue"
        },
        {
            name: "core_selenium-test",
            url: "http://ci.jenkins-ci.org/job/core_selenium-test/",
            color: "red"
        },
        {
            name: "fix-git-configuration-on-remote-slave-8",
            url: "http://ci.jenkins-ci.org/job/fix-git-configuration-on-remote-slave-8/",
            color: "blue"
        },
        {
            name: "infra_accountapp",
            url: "http://ci.jenkins-ci.org/job/infra_accountapp/",
            color: "blue"
        },
        {
            name: "infra_atlassian-base",
            url: "http://ci.jenkins-ci.org/job/infra_atlassian-base/",
            color: "blue"
        },
        {
            name: "infra_backend-confluence-spam-remover",
            url: "http://ci.jenkins-ci.org/job/infra_backend-confluence-spam-remover/",
            color: "blue"
        },
        {
            name: "infra_backend-merge-all-repo",
            url: "http://ci.jenkins-ci.org/job/infra_backend-merge-all-repo/",
            color: "red"
        },
        {
            name: "infra_backend-plugin-report-card",
            url: "http://ci.jenkins-ci.org/job/infra_backend-plugin-report-card/",
            color: "blue"
        },
        {
            name: "infra_backend-war-size-tracker",
            url: "http://ci.jenkins-ci.org/job/infra_backend-war-size-tracker/",
            color: "blue"
        },
        {
            name: "infra_backend_crawler",
            url: "http://ci.jenkins-ci.org/job/infra_backend_crawler/",
            color: "blue"
        },
        {
            name: "infra_backend_jenkins_ci_cloudbess_com_filler",
            url: "http://ci.jenkins-ci.org/job/infra_backend_jenkins_ci_cloudbess_com_filler/",
            color: "blue"
        },
        {
            name: "infra_backend_pull_request_greeter",
            url: "http://ci.jenkins-ci.org/job/infra_backend_pull_request_greeter/",
            color: "blue"
        },
        {
            name: "infra_bind",
            url: "http://ci.jenkins-ci.org/job/infra_bind/",
            color: "blue"
        },
        {
            name: "infra_census_push_to_celery",
            url: "http://ci.jenkins-ci.org/job/infra_census_push_to_celery/",
            color: "blue"
        },
        {
            name: "infra_changelog_refresh",
            url: "http://ci.jenkins-ci.org/job/infra_changelog_refresh/",
            color: "blue"
        },
        {
            name: "infra_checkout_stats",
            url: "http://ci.jenkins-ci.org/job/infra_checkout_stats/",
            color: "blue"
        },
        {
            name: "infra_commit_history_generation",
            url: "http://ci.jenkins-ci.org/job/infra_commit_history_generation/",
            color: "red"
        },
        {
            name: "infra_confluence",
            url: "http://ci.jenkins-ci.org/job/infra_confluence/",
            color: "blue"
        },
        {
            name: "infra_confluence-cache",
            url: "http://ci.jenkins-ci.org/job/infra_confluence-cache/",
            color: "blue"
        },
        {
            name: "infra_drupalcron",
            url: "http://ci.jenkins-ci.org/job/infra_drupalcron/",
            color: "blue"
        },
        {
            name: "infra_extension-indexer",
            url: "http://ci.jenkins-ci.org/job/infra_extension-indexer/",
            color: "red"
        },
        {
            name: "infra_generate_monthly_json",
            url: "http://ci.jenkins-ci.org/job/infra_generate_monthly_json/",
            color: "blue"
        },
        {
            name: "infra_github_repository_list",
            url: "http://ci.jenkins-ci.org/job/infra_github_repository_list/",
            color: "blue"
        },
        {
            name: "infra_ircbot",
            url: "http://ci.jenkins-ci.org/job/infra_ircbot/",
            color: "blue"
        },
        {
            name: "infra_javadoc",
            url: "http://ci.jenkins-ci.org/job/infra_javadoc/",
            color: "blue"
        },
        {
            name: "infra_jenkins-ci.org_jekyll",
            url: "http://ci.jenkins-ci.org/job/infra_jenkins-ci.org_jekyll/",
            color: "blue"
        },
        {
            name: "infra_jenkins-ci.org_webcontents",
            url: "http://ci.jenkins-ci.org/job/infra_jenkins-ci.org_webcontents/",
            color: "blue"
        },
        {
            name: "infra_jira",
            url: "http://ci.jenkins-ci.org/job/infra_jira/",
            color: "blue"
        },
        {
            name: "infra_ldap",
            url: "http://ci.jenkins-ci.org/job/infra_ldap/",
            color: "blue"
        },
        {
            name: "infra_main_svn_to_git",
            url: "http://ci.jenkins-ci.org/job/infra_main_svn_to_git/",
            color: "disabled"
        },
        {
            name: "infra_mirroring",
            url: "http://ci.jenkins-ci.org/job/infra_mirroring/",
            color: "blue"
        },
        {
            name: "infra_mock-ldap",
            url: "http://ci.jenkins-ci.org/job/infra_mock-ldap/",
            color: "red"
        },
        {
            name: "infra_mock-webapp",
            url: "http://ci.jenkins-ci.org/job/infra_mock-webapp/",
            color: "blue"
        },
        {
            name: "infra_patron_messages",
            url: "http://ci.jenkins-ci.org/job/infra_patron_messages/",
            color: "blue"
        },
        {
            name: "infra_plugin-compat-tester",
            url: "http://ci.jenkins-ci.org/job/infra_plugin-compat-tester/",
            color: "blue"
        },
        {
            name: "infra_plugin_changes_report",
            url: "http://ci.jenkins-ci.org/job/infra_plugin_changes_report/",
            color: "red"
        },
        {
            name: "infra_pluginmirror",
            url: "http://ci.jenkins-ci.org/job/infra_pluginmirror/",
            color: "blue"
        },
        {
            name: "infra_plugins_svn_to_git",
            url: "http://ci.jenkins-ci.org/job/infra_plugins_svn_to_git/",
            color: "disabled"
        },
        {
            name: "infra_pull_m2repo",
            url: "http://ci.jenkins-ci.org/job/infra_pull_m2repo/",
            color: "aborted"
        },
        {
            name: "infra_release.rss",
            url: "http://ci.jenkins-ci.org/job/infra_release.rss/",
            color: "blue"
        },
        {
            name: "infra_repo.jenkins-ci.org_maven_index",
            url: "http://ci.jenkins-ci.org/job/infra_repo.jenkins-ci.org_maven_index/",
            color: "blue"
        },
        {
            name: "infra_robobutler",
            url: "http://ci.jenkins-ci.org/job/infra_robobutler/",
            color: "blue"
        },
        {
            name: "infra_statistics",
            url: "http://ci.jenkins-ci.org/job/infra_statistics/",
            color: "blue"
        },
        {
            name: "infra_svnsync",
            url: "http://ci.jenkins-ci.org/job/infra_svnsync/",
            color: "disabled"
        },
        {
            name: "infra_sync_maven-hpi-plugin_www",
            url: "http://ci.jenkins-ci.org/job/infra_sync_maven-hpi-plugin_www/",
            color: "red"
        },
        {
            name: "infra_update_center",
            url: "http://ci.jenkins-ci.org/job/infra_update_center/",
            color: "disabled"
        },
        {
            name: "infra_update_center_experimental",
            url: "http://ci.jenkins-ci.org/job/infra_update_center_experimental/",
            color: "disabled"
        },
        {
            name: "infra_update_center_mirror",
            url: "http://ci.jenkins-ci.org/job/infra_update_center_mirror/",
            color: "blue"
        },
        {
            name: "infra_update_center_stable",
            url: "http://ci.jenkins-ci.org/job/infra_update_center_stable/",
            color: "disabled"
        },
        {
            name: "infra_update_center_v3",
            url: "http://ci.jenkins-ci.org/job/infra_update_center_v3/",
            color: "blue"
        },
        {
            name: "infra_update_mave_site",
            url: "http://ci.jenkins-ci.org/job/infra_update_mave_site/",
            color: "blue"
        },
        {
            name: "jenkins_lts_branch",
            url: "http://ci.jenkins-ci.org/job/jenkins_lts_branch/",
            color: "blue"
        },
        {
            name: "jenkins_main_maven-3.1.0",
            url: "http://ci.jenkins-ci.org/job/jenkins_main_maven-3.1.0/",
            color: "blue"
        },
        {
            name: "jenkins_main_trunk",
            url: "http://ci.jenkins-ci.org/job/jenkins_main_trunk/",
            color: "yellow"
        },
        {
            name: "jenkins_pom",
            url: "http://ci.jenkins-ci.org/job/jenkins_pom/",
            color: "red"
        },
        {
            name: "jenkins_rc_branch",
            url: "http://ci.jenkins-ci.org/job/jenkins_rc_branch/",
            color: "yellow"
        },
        {
            name: "jenkins_ui-changes_branch",
            url: "http://ci.jenkins-ci.org/job/jenkins_ui-changes_branch/",
            color: "red"
        },
        {
            name: "kohsuke_github-api",
            url: "http://ci.jenkins-ci.org/job/kohsuke_github-api/",
            color: "blue"
        },
        {
            name: "lib-jenkins-maven-artifact-manager",
            url: "http://ci.jenkins-ci.org/job/lib-jenkins-maven-artifact-manager/",
            color: "blue"
        },
        {
            name: "lib-jenkins-maven-embedder",
            url: "http://ci.jenkins-ci.org/job/lib-jenkins-maven-embedder/",
            color: "blue"
        },
        {
            name: "lib-jira-api",
            url: "http://ci.jenkins-ci.org/job/lib-jira-api/",
            color: "red"
        },
        {
            name: "libs_core-js",
            url: "http://ci.jenkins-ci.org/job/libs_core-js/",
            color: "blue"
        },
        {
            name: "libs_dom4j",
            url: "http://ci.jenkins-ci.org/job/libs_dom4j/",
            color: "blue"
        },
        {
            name: "libs_htmlunit",
            url: "http://ci.jenkins-ci.org/job/libs_htmlunit/",
            color: "aborted"
        },
        {
            name: "libs_jelly",
            url: "http://ci.jenkins-ci.org/job/libs_jelly/",
            color: "blue"
        },
        {
            name: "libs_jexl",
            url: "http://ci.jenkins-ci.org/job/libs_jexl/",
            color: "blue"
        },
        {
            name: "libs_jmdns",
            url: "http://ci.jenkins-ci.org/job/libs_jmdns/",
            color: "blue"
        },
        {
            name: "libs_json-lib",
            url: "http://ci.jenkins-ci.org/job/libs_json-lib/",
            color: "blue"
        },
        {
            name: "libs_maven-jetty-plugin",
            url: "http://ci.jenkins-ci.org/job/libs_maven-jetty-plugin/",
            color: "blue"
        },
        {
            name: "libs_netx",
            url: "http://ci.jenkins-ci.org/job/libs_netx/",
            color: "blue"
        },
        {
            name: "libs_svnkit",
            url: "http://ci.jenkins-ci.org/job/libs_svnkit/",
            color: "red"
        },
        {
            name: "libs_trilead-ssh2",
            url: "http://ci.jenkins-ci.org/job/libs_trilead-ssh2/",
            color: "blue"
        },
        {
            name: "libs_winstone",
            url: "http://ci.jenkins-ci.org/job/libs_winstone/",
            color: "blue"
        },
        {
            name: "libs_xstream",
            url: "http://ci.jenkins-ci.org/job/libs_xstream/",
            color: "blue"
        },
        {
            name: "maven-interceptors",
            url: "http://ci.jenkins-ci.org/job/maven-interceptors/",
            color: "blue"
        },
        {
            name: "model-ant-project",
            url: "http://ci.jenkins-ci.org/job/model-ant-project/",
            color: "blue"
        },
        {
            name: "model-ruby-project",
            url: "http://ci.jenkins-ci.org/job/model-ruby-project/",
            color: "blue"
        },
        {
            name: "peripheral apps deactivation prevention",
            url: "http://ci.jenkins-ci.org/job/peripheral%20apps%20deactivation%20prevention/",
            color: "blue"
        },
        {
            name: "plugin-compat-tester",
            url: "http://ci.jenkins-ci.org/job/plugin-compat-tester/",
            color: "disabled"
        },
        {
            name: "remoting",
            url: "http://ci.jenkins-ci.org/job/remoting/",
            color: "blue"
        },
        {
            name: "selenium-tests",
            url: "http://ci.jenkins-ci.org/job/selenium-tests/",
            color: "red"
        },
        {
            name: "test-matrix",
            url: "http://ci.jenkins-ci.org/job/test-matrix/",
            color: "notbuilt"
        },
        {
            name: "tools_maven-hpi-plugin",
            url: "http://ci.jenkins-ci.org/job/tools_maven-hpi-plugin/",
            color: "blue"
        },
        {
            name: "tools_maven-hpi-plugin-maven-2.x",
            url: "http://ci.jenkins-ci.org/job/tools_maven-hpi-plugin-maven-2.x/",
            color: "blue"
        }
    ],
    overallLoad: {

    },
    primaryView: {
        name: "All Failed",
        url: "http://ci.jenkins-ci.org/"
    },
    quietingDown: false,
    slaveAgentPort: 47278,
    unlabeledLoad: {

    },
    useCrumbs: false,
    useSecurity: true,
    views: [
        {
            name: "All",
            url: "http://ci.jenkins-ci.org/view/All/"
        },
        {
            name: "All Disabled",
            url: "http://ci.jenkins-ci.org/view/All%20Disabled/"
        },
        {
            name: "All Failed",
            url: "http://ci.jenkins-ci.org/"
        },
        {
            name: "All Unstable",
            url: "http://ci.jenkins-ci.org/view/All%20Unstable/"
        },
        {
            name: "Infrastructure",
            url: "http://ci.jenkins-ci.org/view/Infrastructure/"
        },
        {
            name: "Jenkins core",
            url: "http://ci.jenkins-ci.org/view/Jenkins%20core/"
        },
        {
            name: "Libraries",
            url: "http://ci.jenkins-ci.org/view/Libraries/"
        },
        {
            name: "Other Projects",
            url: "http://ci.jenkins-ci.org/view/Other%20Projects/"
        }
    ]
}
johnbeech commented 9 years ago

This works:


<jenkins-jobs data-source-url="/api/connectedTvCloudJenkins" refresh-time="10"></jenkins-jobs>

<template for="jenkins-jobs">
  {{#each jobs}}
  <a href="{{url}}">
    <button class="btn btn-{{alertType}}">{{name}} : {{color}}</button>
  </a>
  {{/each}}
</template>

<style for="jenkins-jobs">
  jenkins-jobs > a {
    margin: 5px 0;
    display: inline-block;
    text-decoration: none;
  }
</style>

<script type="text/javascript" for="jenkins-jobs">
  $(function() {
    var JenkinsJobComponent = Component.configure('jenkins-jobs');

    JenkinsJobComponent.prototype.selectAlertType = function(jenkinsColor) {
      return ({
        "red": 'danger',
        "blue": 'success',
        "blue_anime": 'info'
      })[jenkinsColor] || 'danger';
    }

    JenkinsJobComponent.on('preRenderStep', function(instance) {
      try {
        var list = instance.jobs;
        if (list) {
          for (key in list) {
            var item = list[key];
            item.alertType = instance.selectAlertType(item.color);
            item.url = instance.data.service + '/job/' + item.name;
          }
        }
      } catch (e) {
        // do nothing
      }
    });
  });
</script>
Markavian commented 9 years ago

Rolling with a slightly more advanced implementation here: https://github.com/connected-tv/connected-tv-app-monitor/blob/master/config/content/index.content.html

Probably needs componentising, using the compiler feature of Web Component JS (when its ready), see: https://github.com/connected-web/web-component-js/issues/7

Markavian commented 9 years ago

Me thinks this would also be a good candidate for a plugin, see #32...