Last active
May 29, 2018 14:34
-
-
Save makepanic/a87e96dfd21583b96eb3 to your computer and use it in GitHub Desktop.
Revisions
-
makepanic renamed this gist
Dec 26, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
makepanic revised this gist
Dec 26, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ The MIT License (MIT) Copyright (c) 2014 Christian Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -
makepanic created this gist
Dec 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ The MIT License (MIT) Copyright (c) 2014 David Underwood Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ ##Preview  ## Description Simple [Dashing](http://shopify.github.com/dashing) widget (and associated job) to display teamcity build info. Based on [DefactoSoftware/dashing-widgets/teamcity](https://github.com/DefactoSoftware/dashing-widgets/tree/master/teamcity). This widgets displays all children of a teamcity project. Each child project displays the latest build in each branch that is registered in teamcity. If a build has the state `FAILURE` the widgets flashes in red (see gif). ##Dependencies [teamcity-ruby-client](https://github.com/jperry/teamcity-ruby-client) Add it to dashing's gemfile: gem 'teamcity-ruby-client' and run `bundle install`. Everything should work now :) ##Usage - Copy the `team_city.coffee`, `team_city.html` and `team_city.scss` files from this gist to the `widgets/team_city`. - Copy `teamcity.rb` to `jobs/` - Copy `teamcity.yml` to `config/` To include the widget in a dashboard, add the following snippet to the dashboard layout file: <li data-row="1" data-col="1" data-sizex="1" data-sizey="3"> <div data-id="template-data-id1" data-image="/project-icon.png" data-view="TeamCity" data-unordered="true" data-title="TITLE"></div> </li> ##Settings Modify the `teamcity.yml` config file to work in your teamcity setup. See [https://github.com/jperry/teamcity-ruby-client](https://github.com/jperry/teamcity-ruby-client) for more information on the teamcity api auth. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ class Dashing.TeamCity extends Dashing.Widget This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <h1 class="title" data-bind="title"></h1> <img data-bind-src="image | prepend '/assets'" data-bind-width="width"/> <ul class="list-nostyle"> <li data-foreach-item="items"> <ul> <li class="project" data-foreach-item="item.projects"> <h3 class="project-name" data-bind="item.name"></h3> <ul class="builds" > <li data-foreach-item="item.build_types" data-bind-class="item.last_build.status"> <p> <strong class="build-type-name" data-bind="item.name"></strong> #<span data-bind="item.last_build.number"></span> </p> </li> </ul> </li> </ul> </li> </ul> <p class="more-info" data-bind="moreinfo"></p> <p class="updated-at" data-bind="updatedAtMessage"></p> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,120 @@ // ---------------------------------------------------------------------------- // Sass declarations // ---------------------------------------------------------------------------- $value-color: #FFF; $background-error-color: #E64040; $background-passed-color: rgba(111, 214, 85, 0.66); $background-started-color: #E7D100; $background-no-status-color: rgba(115, 115, 115, 0.73); $title-color: rgba(255, 255, 255, 1); $label-color: rgba(255, 255, 255, 0.7); $moreinfo-color: rgba(255, 255, 255, 0.7); $background: #444; @mixin keyframes($animation-name) { @-webkit-keyframes #{$animation-name} { @content; } @-moz-keyframes #{$animation-name} { @content; } @-ms-keyframes #{$animation-name} { @content; } @-o-keyframes #{$animation-name} { @content; } @keyframes #{$animation-name} { @content; } } @mixin animation($args...) { -webkit-animation: $args; -moz-animation: $args; -ms-animation: $args; -o-animation: $args; animation: $args; } @include keyframes(blink) { 0% { opacity: 1.0; } 50% { opacity: 0.0; } 100% { opacity: 1.0; } } // ---------------------------------------------------------------------------- // Widget-list styles // ---------------------------------------------------------------------------- .widget-team-city{ background-color: $background; vertical-align: top !important; h1{ text-transform: uppercase; } h3{ font-size: 20px; margin: 5px 0; font-weight: lighter; } img { position: absolute; top: 30px; left: 50px; margin: 0 auto; opacity: 0.05; max-width: 80%; max-height: 80%; } .title, strong{ color: $title-color; } ul { margin: 0; text-align: left; list-style: none; color: $label-color; } li { margin-bottom: 5px; } .project{ .project-name{ } } .builds{ p{ padding: 10px; } li{ background-color: $background-no-status-color; } margin-bottom: 5px; .SUCCESS{ background-color: $background-passed-color; } .FAILURE{ background-color: $background-error-color; @include animation(blink 1s step-start 0s infinite); } .build-type-name{ font-size: 20px; } } .updated-at { color: rgba(0, 0, 0, 0.3); } .more-info { color: $moreinfo-color; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ require 'teamcity' def update_builds(project_id) builds = [] projects = [] TeamCity.project(:id => project_id).projects.project.each do |project| build_types = [] TeamCity.project_buildtypes(:id => project.id).each do |build_type| build_types.push({ :id => build_type.id, :name => build_type.name }) end build_types.each do |build_type_obj| build_type_obj_builds = TeamCity.builds(:count => 1, :buildType => build_type_obj[:id]) unless build_type_obj_builds.nil? last_build = build_type_obj_builds.first build_type_obj['last_build'] = { :id => last_build.id, :number => last_build.number, :state => last_build.state, :status => last_build.status } end end projects.push({ :name => project.name, :id => project.id, :description => project.description, :build_types => build_types }) end build_info = { :title => project_id, :projects => projects } builds << build_info builds end config_file = File.dirname(File.expand_path(__FILE__)) + '/../config/teamcity.yml' config = YAML::load(File.open(config_file)) TeamCity.configure do |c| c.endpoint = config['api_url'] c.http_user = config['http_user'] c.http_password = config['http_password'] end SCHEDULER.every '33s', :first_in => '1s' do if config['repositories'].nil? puts 'No TeamCity repositories found :(' else config['repositories'].each do |data_id, build_id| send_event(data_id, { :items => update_builds(build_id)}) end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ api_url: "https://my-teamcity-installation.tld/httpAuth/app/rest/" http_user: "my-http-user" http_password: "my-http-password" repositories: template-data-id1: project1Id template-data-id2: project2Id