{"id":15605736,"url":"https://github.com/ajitsing/gocd","last_synced_at":"2025-05-07T13:45:01.807Z","repository":{"id":56874716,"uuid":"68476997","full_name":"ajitsing/gocd","owner":"ajitsing","description":"Gem to fetch gocd information easily","archived":false,"fork":false,"pushed_at":"2018-10-22T15:20:32.000Z","size":74,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-24T17:44:18.803Z","etag":null,"topics":["ci","continuous-delivery","continuous-deployment","continuous-integration","gem","gocd","goconfig","pipeline","ruby","rubygem"],"latest_commit_sha":null,"homepage":"http://www.singhajit.com/ruby-gem-to-fetch-information-gocd-rich-models/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajitsing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-17T20:39:57.000Z","updated_at":"2018-12-10T15:41:31.000Z","dependencies_parsed_at":"2022-08-20T10:11:06.357Z","dependency_job_id":null,"html_url":"https://github.com/ajitsing/gocd","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitsing%2Fgocd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitsing%2Fgocd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitsing%2Fgocd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitsing%2Fgocd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajitsing","download_url":"https://codeload.github.com/ajitsing/gocd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242980588,"owners_count":20216283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","continuous-delivery","continuous-deployment","continuous-integration","gem","gocd","goconfig","pipeline","ruby","rubygem"],"created_at":"2024-10-03T04:14:12.609Z","updated_at":"2025-03-11T05:32:08.888Z","avatar_url":"https://github.com/ajitsing.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gocd\n\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/ajitsing/gocd/graphs/commit-activity)\n[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://opensource.org/licenses/Apache-2.0)\n[![Gem Version](https://badge.fury.io/rb/gocd.svg)](https://badge.fury.io/rb/gocd)\n[![HitCount](http://hits.dwyl.io/ajitsing/gocd.svg)](http://hits.dwyl.io/ajitsing/gocd)\n![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/gocd?type=total)\n[![Build Status](https://travis-ci.org/ajitsing/gocd.svg?branch=master)](https://travis-ci.org/ajitsing/gocd)\n[![Twitter Follow](https://img.shields.io/twitter/follow/Ajit5ingh.svg?style=social)](https://twitter.com/Ajit5ingh)\n\n### Installation\n```ruby\ngem 'gocd'\n```\n\nor\n\n```bash\ngem install gocd\n```\n\n### Code Documentation\nhttp://www.rubydoc.info/gems/gocd/1.3\n\n### Usage\n\n```ruby\nGOCD.server = GOCD::Server.new 'http://goserverurl.com'\nGOCD.credentials = GOCD::Credentials.new 'username', 'password'\n```\n\n###### To check all pipelines:\n```ruby\nGOCD::AllPipelines.red_pipelines\n```\n\n###### To check a group of pipelines:\n\n```ruby\npipelines = GOCD::PipelineGroup.new ['Pipeline1 :: stage1', 'Pipeline1 :: stage2', 'Pipeline2 :: stage1']\npipelines.red_pipelines\npipelines.status\npipelines.any_red?\n```\n\n#### Cache\nBy default all methods in ```GOCD::AllPipelines``` and ```GOCD::PipelineGroup``` make a call to go api to fetch the latest status of pipelines. This can be avoided using cache. To enable cache just pass ```cache: true``` when you call any of the method in ```GOCD::AllPipelines``` and ```GOCD::PipelineGroup```.\n\n```ruby\nGOCD::AllPipelines.any_red?(cache: true)\nGOCD::AllPipelines.red_pipelines(cache: true)\nGOCD::AllPipelines.green_pipelines(cache: true)\nGOCD::AllPipelines.status(cache: true)\n```\n\n```ruby\npipelines = GOCD::PipelineGroup.new(['Pipeline1 :: stage1'], cache: true)\npipelines.red_pipelines # will return red pipelines from cache\npipelines.status # will return pipelines status from cache\npipelines.any_red?(cache: false) # will check with the latest pipelines\n```\n\n#### Want to create your own gocd dashboard? Its easy now!\n```ruby\nrequire 'sinatra'\nrequire 'gocd'\n\nget '/' do\n  GOCD.server = GOCD::Server.new 'http://goserverurl.com'\n  GOCD.credentials = GOCD::Credentials.new 'username', 'password'\n  GOCD::AllPipelines.red_pipelines(cache: false).map {|pipeline| pipeline.to_hash}.to_json\nend\n```\n\n#### Go Agents\n###### To get all the idle agents:\n```ruby\nidle_agents = GOCD::Agents.idle\nidle_agents.each { |agent| agent.name }\n```\n\n###### To get all the missing agents:\n```ruby\nGOCD::Agents.missing\n```\n\n###### To get all the disabled agents:\n```ruby\nGOCD::Agents.disabled\n```\n\n#### Pipeline Configuration\n\n###### Get all the environments\n```ruby\ninclude GOCD::PIPELINE_CONFIG\n\nenvironments #returns all the environments and the whole hierarchy of it\n```\n\n###### Get all the pipelines\n```ruby\ninclude GOCD::PIPELINE_CONFIG\n\npipelines = environments.map(\u0026:pipelines).flatten\n```\n\n###### Get all the stages\n```ruby\ninclude GOCD::PIPELINE_CONFIG\n\nstages = environments.map(\u0026:pipelines).flatten.map(\u0026:stages).flatten\n```\n\n###### Get all the jobs\n```ruby\ninclude GOCD::PIPELINE_CONFIG\n\njobs = environments.map(\u0026:pipelines).flatten.map(\u0026:stages).flatten.map(\u0026:jobs).flatten\n```\n\n#### History Fetcher\nYou can fetch history of a job using the HistoryFetcher APIs\n```ruby\nrequire 'gocd'\n\nGOCD.server = GOCD::Server.new 'http://goserverurl.com'\nGOCD.credentials = GOCD::Credentials.new 'username', 'password'\n\ninclude GOCD::PIPELINE_CONFIG\n\nhistories = []\nruns = 1000\njobs = environments.map(\u0026:pipelines).flatten.map(\u0026:stages).flatten.map(\u0026:jobs).flatten\njobs.each do |job|\n  histories \u003c\u003c GOCD::HistoryFetcher.fetch_job_history(job, runs)\nend\n```\n\nLICENSE\n-------\n\n```LICENSE\nCopyright (C) 2016 Ajit Singh\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajitsing%2Fgocd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajitsing%2Fgocd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajitsing%2Fgocd/lists"}