CircleCI notifications in RocketChat

There is no official CircleCI integration for RocketChat, therefore this has to be done a little manually.

Below is an example of how I use it.

.circleci/config.yml

version: 2
jobs:
  build-development:
    docker:
      - image: debian:stretch
    steps:
        - checkout
        - run: 
            command: apt-get update && apt-get install -y curl
        - run:
            name: Greeting from hello
            command: echo "Hello, world from hello."
        - run:
            name: Notifiation Failed
            command: bash .circleci/notify "failed"
            when: on_fail
        - run:
            name: Notification Sucess
            command: bash ./circleci/notify "success"
            when: on_success
        
workflows:
  version: 2
  build-deploy:
    jobs:
      - build-development
          filters:
            branches:
              only:
                - develop

Note that on_fail will only execute if one of the above will fail, same with on_success, it only executes if all of the above are successful.

.circleci/notify


#!/bin/bash
set -euo pipefail

payload=$(
cat <<EOM
{
    "status": "$1",
    "job": "$CIRCLE_JOB",
    "build_num": "$CIRCLE_BUILD_NUM",
    "project_reponame": "$CIRCLE_PROJECT_REPONAME",
    "branch": "$CIRCLE_BRANCH",
    "build_url": "$CIRCLE_BUILD_URL",
    "compare_url": "$CIRCLE_COMPARE_URL",
    "sha1": "$CIRCLE_SHA1"
}
EOM
)

curl -X POST -H 'Content-Type: application/json' --data "$payload" https://YOUR-ROCKETCHAT/hooks/INCOMING-WEBHOOK-INTEGRATION-URL

RocketChat Incoming WebHook Integration

class Script {
  
  process_incoming_request({ request }) {
     
    var alertColor = "warning";
    
    let status = request.content.status;
    let job = request.content.job;
    let build_num = request.content.build_num;
    let project_reponame = request.content.project_reponame;
    let branch = request.content.branch;
    let build_url = request.content.build_url;
    let sha1 = request.content.sha1;
      
    if (status == "success") {
    	alertColor = "good";
    } else if (status == "failed") {
    	alertColor = "danger";
    }

    let textMessage = (status == "failed" ? "@all\n" : "");
        
    let title = status == "failed" ? " build failed!" : " was built successfully!"
    
    textMessage = textMessage + "*Build no*: " + build_num + "\n*Project*: " + project_reponame + "\n*Branch*: " + branch + "\n*Commit*: " + sha1

    return {
    	content: {
	    username: "CircleCI",
            attachments: [{
		text: textMessage,
                color: alertColor,
                title: job + title,
                title_link: build_url
            }]
        }
    };

    return {
    	error: {
        	success: false
        }
    };
  }
}

Windows vs. Mac OS X vs. Linux: The Operating System Battle

Windows, Mac OS X, or Linux? That has been the age-old dilemma that is now gaining more and more attention as each operating system is progressing at a record pace. This summary will give you a comprehensive and thorough examination of each operating system, their advantages, disadvantages, and a final summary of which one is better. Please note that all conclusions are self-drawn opinions that are supported by facts. However, it does not guarantee that these thoughts are truths. Continue reading “Windows vs. Mac OS X vs. Linux: The Operating System Battle”

Open source wars: WordPress vs Drupal vs Joomla

Every IT person, developer, and programmer has an opinion when it comes to the various open source content management systems out there. It often comes down to functionality and ease of use, but even then the lines are often blurred and there is rarely a clear-cut victor. WordPress vs Drupal vs Joomla – which is really the king of open source CMS? Continue reading “Open source wars: WordPress vs Drupal vs Joomla”

How to change VLC player skin

We all like VLC its the best Video player ever, simply it rocks.. but sometimes we like to see it on another skin..

Peace of cake !

Here’s how we do it :
Go to this page http://www.videolan.org/vlc/skins.php and download any of the skins you like….
I’m gonna get the WinShit Media Player : http://www1.videolan.org/vlc/download-skins2-go.php?url=WMP_B_2.vlt

Open VLC and go to Tools > Preferences

Now Under the Interface Tab enable Skins as shown in photo Browse the file that you downloaded from the site above and click save… Continue reading “How to change VLC player skin”