Giter VIP home page Giter VIP logo

hubot-yardmaster's Introduction

Hubot Yardmaster

Yardmaster is a Hubot plugin that allows you to interact with Jenkins instance remotely. Build jobs, change branches, start builders, lock jobs... The list goes on.

Environment Variables Required:

  • HUBOT_JENKINS_URL - Jenkins base URL
  • HUBOT_JENKINS_USER - Jenins admin user
  • HUBOT_JENKINS_USER_API_KEY - Admin user API key. Not your password. Find at "{HUBOT_JENKINS_URL}/{HUBOT_JENKINS_USER}/configure"
  • HUBOT_JENKINS_JOB_NAME - Hubot job name on Jenkins (optional)
  • GITHUB_TOKEN - Github API Auth token (optional)
  • MONITOR_JENKINS - true | false : If true, hubot will monitor the jenkins queue and start nodes when job queue is greater than 2.

Commands:

  • hubot jenkins auth set {username} {api key} - Give Hubot your credentials to use when you issue commands.
  • hubot jenkins auth - See what Jenkins username the Hubot has for you.
  • hubot jenkins auth clear - Clear your Jenkins credentials.
  • hubot switch|change|build {job} to|with {branch} - Change job to branch on Jenkins and build.
  • hubot (show|current|show current) branch for {job} - Shows current branch for job on Jenkins.
  • hubot (go) build yourself|(go) ship yourself - Rebuilds default branch if set.
  • hubot list jobs|jenkins list|all jobs|jobs {job} - Shows all jobs in Jenkins. Filters by job if provided.
  • hubot build|rebuild {job} [PARAM1=VALUE1 PARAM2=VALUE2 ...] - Rebuilds job, optionally with parameters.
    • The parameter names must match those defined in Jenkins and currently values cannot have spaces in them.
  • hubot build|rebuild {job}
  • hubot enable|disable {job} - Enable or disable job on jenkins.
  • hubot show|show last|last (build|failure|output) for {job} - show output for last job
  • hubot show|show output|output for {job} {number} - show output job output for number given
  • hubot set branch message to {message} - set custom message when switching branches on a job
  • hubot remove branch message - remove custom message. Uses default message.
  • hubot show|show last|last (build|failure|output) for {job} - show output for last job.
  • hubot show|show output|output for {job} {number} - show output job output for number given.
  • hubot {job} status - show current build status and percent compelete of job and its dependencies.
  • hubot set job repos - Pulls list of jobs and repos from jenkins and places in memory to validate branch names if github token provided.
  • hubot remove job repos - Will remove job repos from memory.
  • hubot watch job {job-url} - Will check job every minute and notify you on completion
  • hubot (show|show last|last) (build) (date|time) for {job} - shows the last build date and time for a job
  • hubot (start|build) (builder|slave|node) - starts one of the available slave nodes.
  • hubot send reinforcements - starts one of the available slave nodes.

Author:

@riveramj

hubot-yardmaster's People

Contributors

farmdawgnation avatar riveramj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hubot-yardmaster's Issues

output of job

i want to see the output of a job - either last or by id

Ability to check whether a branch exists against Github repo for a job

When we ask hubot to switch a job to a branch, it would be handy to double-check whether that branch is valid before firing off a build that will fail.

Some thoughts:

  • This can be read from Jenkins config and cached in the brain.
  • Users who want it re-read would clear the brain (if it becomes a common use
    case, possibly providing an interface for it would make sense, but not for now).
  • Github credentials would be needed.
  • This would be optional, so if no github credentials are present, we could skip
    the validation altogether. Or, if the remote repo isn't in github, same deal.

Modularize

I think it's probably time to modularize this thing a bit.

There are a few dividing lines I can see immediately... things like

  1. Core Jenkins interactions (auth/http methods/etc)
  2. "Job" things (e.g. changing the branch)
  3. "Build" things (reading output, watching)
  4. Helper methods.
  5. The message regexes etc

WDYT? Does this seem like a reasonable division? I could whip up a sample PR at some point soon if so.

ERROR TypeError: Cannot read property 'replace' of undefined

Hubot is reporting an error when running some commands but not all.

hubot show last build for

[Thu Sep 03 2015 17:19:10 GMT-0700 (PDT)] ERROR TypeError: Cannot read property 'replace' of undefined
at /home/jenkins-slave/jarvis/node_modules/hubot-yardmaster/src/yardmaster.coffee:214:17, :227:38
at /home/jenkins-slave/jarvis/node_modules/hubot-yardmaster/src/yardmaster.coffee:67:9, :37:16
at IncomingMessage. (/home/jenkins-slave/jarvis/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)

List all jobs

Need to be able to list all jobs that are on jenkins currently

RangeError on watch command

Running "hubot watch job " gives me the following error:

Aug 08 15:44:08 server hubot[3080]: [Mon Aug 08 2016 15:44:08 GMT+0200 (CEST)] INFO [Incoming] pontius: hubot watch job https://<server>/job/<jobname>
Aug 08 15:44:08 server hubot[3080]: [Mon Aug 08 2016 15:44:08 GMT+0200 (CEST)] INFO Message sent to hubot brain.
Aug 08 15:44:09 server hubot[3080]: [Mon Aug 08 2016 15:44:09 GMT+0200 (CEST)] ERROR RangeError: Maximum call stack size exceeded
Aug 08 15:44:09 server hubot[3080]:   at RegExp.test (native)
Aug 08 15:44:09 server hubot[3080]:   at trimUrl (/opt/hubot/node_modules/hubot-yardmaster/src/yardmaster.coffee:503:3, <js>:589:26)
Aug 08 15:44:09 server hubot[3080]:   at trimUrl (/opt/hubot/node_modules/hubot-yardmaster/src/yardmaster.coffee:507:5, <js>:593:14)
Aug 08 15:44:09 server hubot[3080]:   at trimUrl (/opt/hubot/node_modules/hubot-yardmaster/src/yardmaster.coffee:507:5, <js>:593:14)
Aug 08 15:44:09 server hubot[3080]:   at trimUrl (/opt/hubot/node_modules/hubot-yardmaster/src/yardmaster.coffee:507:5, <js>:593:14)
[...]

Branch locking

It would be nice if yardmaster allow for branch locking when certain jobs are deployed. Essentially, this is intended to address the problem of two people on the same team not realizing that the other needs to use the job in question.

Opting-in to locking

Locking would be turned off by default. I would envision turning it on looking something like

Hubot, enable locking for

At this point, the Hubot knows what the default branch for the job in question is. You could likewise disable locking for a particular job.

Hubot, disable locking for

Switching when locking is active

When locking is active for a job, yardmaster will require some extra information in order to switch a build over to the non-default branch. To switch a job to a feature branch you'd need to provide something like the following:

Hubot, switch to for

At this point, the reason for the branch switch has been logged. When the developer who is doing the testing is finished, they can say

Hubot, switch to

And the build is now considered unlocked and free for anyone to switch. However, if another developer tries to come in and deploy a second feature branch on top of the first one, let's say Mike tried to deploy a feature branch while Antonio was testing something, something like the following exchange would occur:

Mike: Hubot, switch alan-shepherd to awesome-sauce
Hubot: Sorry, Mike. Antonio is using alan-shepherd to test super-cool-branch-name for "super secret testing reason" since 7/23/2014 at 10:00 AM EST.

At this point Mike has two options.

  1. Tell Antonio to hurry the heck up and have Antonio unlock the build.
  2. Force the switch.

Hubot, force switch to for

A force switch overrides the lock functionality, but ideally shouldn't be used unless the developer who was using the job is unreachable for some reason.

How does this bot suppose to work?

I have a hubot running fine in Slack. I now want to add the Jenkins functionality provided by this module.

I run it like this:

HUBOT_SLACK_TOKEN=*** HUBOT_JENKINS_URL=https://**** HUBOT_JENKINS_USER=**@***.*** HUBOT_JENKINS_USER_API_KEY=**** ./bin/hubot --adapter slack

I check that the bot still works. Then I call any of the commands provided by this module but nothing works...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.