Wednesday 14 October 2015

INTEGRATING HUBOT WITH HIPCHAT


Creating Hipchat account for one admin and two users

FOR ADMIN

1. Goto www.hipchat.com

  • sign-up (Full Name, Working Email)
  • Create new team
  • Click on “No thanks, I’ll send invites later”
  • Click on Hipchat logo on top left corner
  • Group admin Users Add

The above step will add users and send invitation to their mail.

FOR USERS

2. Check your mail and join the invitation

  • Fill in details with working mail id
  • Click on Launch the web app“

3. Installing node.js and npm

4. Installing hubot yeoman generator

5. Installing the Heroku Toolbelt

6. Clone the repository

7. Configure it


$ heroku config:add HEROKU_URL=http://.herokuapp.com

Go to hipchat home page (not chat page) of one of the user or admin Accoount settings → XMPP/Jabber info

$ heroku config:add HUBOT_HIPCHAT_JID="id from above"
$ heroku config:add HUBOT_HIPCHAT_PASSWORD="password when you created account"


Logout the hipchat account which you have just registered for robot, here in this case we chose admin account for hubot.
Check on both user hipchat account that admin green bubble turned grey ;)  
8. Deploy your changes

9. Running process

AS soon as the above process run, check the hipchat user account, bot’s bubble turned to green and available.

Go to one of the room and check by texting @<your_bot_name> help, it’ll respond with some set of instructions.

[Below are some useful commands]

Stopping process
Current process state
Checking log
Restart heroku

Monday 12 October 2015

KICK START WITH JENKINS JOB BUILDER(JJB)

What is JJB?

It’s a YAML file that enable us to write jenkins job description in human readable format and store in VCS to manage versioning on them.

Who created JJB?

Openstack Infra team.

Why JJB is created?

Jobs are stored in CI server in XML format which is not best readable format to write jenkins jobs manually so they came with JJB to manage jobs at graphical interface level.


Prerequisite:

All these commands should be run on Jenkins server

$ sudo apt-get install python-yaml
$ sudo apt-get install python-dev python-pip
$ cd jenkins-job-builder
$ sudo pip install --user -e .
$ sudo python setup.py install

Configuration:

$ nano /etc/jenkins_jobs/jenkins_jobs.ini 

[job_builder]
allow_duplicates=True
[jenkins]
user=USERNAME
password=PASSWORD
url=jenkins_url(http://localhost:8080)


Test a YAML job definition:

$ jenkins-jobs test tests/yamlparser/fixtures/templates002.yaml

The above command prints the generated Jenkins XML to the console. If you prefer to send it to a directory use following command.

$ jenkins-jobs test -o output tests/yamlparser/fixtures/templates002.yaml

The output directory will contain files with the XML configurations.

Updating Jenkins Jobs:

$  jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update

tests/yamlparser/fixtures/templates002.yaml

OR

$ jenkins-jobs update tests/yamlparser/fixtures/templates002.yaml

The above command will update your Jenkins master with the generated jobs.

Deleting a job:

$ jenkins-jobs --conf etc/jenkins_jobs.ini delete <job-name>

Reference doc:

http://docs.openstack.org/infra/jenkins-job-builder/quick-start.html


Example: my-job.yaml

 - job:
name: my-first-job-test
description: "Checking system's uptime and polling job every minute"
project-type: freestyle
block-downstream: false
triggers:
- pollscm: '*/1 * * * *'
builders:
           - shell: |
uptime
publishers:
- email:
          recipients: test@test.com