How to trigger a Jenkins build from Slack

As you know, Slack is a great product for team communication. And Jenkins help you setup a automation build (Continuous Integration). In this article, I will show the way how to use Slack Commands to trigger a Jenkins build.

Golang or Gohome T-Shirt

Buy Golang or Gohome t-shirt

In your Jenkins, you install Build Authorization Token Root Plugin, as image below

Build-Authorization-Token-Root-Plugin

 

In configuration job Jenkins, you check “trigger builds remotely” and add a token (you can get a random token here). See image below

29-01-2015 2-15-02 CH

So now, you can trigger a remote build by url:

For details, you can read https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin

In your Slack, you create a Slack Commands in Slack (e.g: /build_example).

Command textbox, type “/build_example”

URL textbox, add http://[jenkins_url]/buildByToken/buildWithParameters?job=[job_name]&token=[your_token]&[param=value]

Method combobox, choose GET. Finally, click “Save”

29-01-2015 2-24-25 CH

To test your work, go to Slack chat page, you type “/build_example” and check the result.

If you want to build with parameters from Slack (e.g /build [branch]). You need write a proxy script to handle the build. You can take a look to https://github.com/thanhson1085/slack-jenkins as a example

67071ae5-5df4-49f7-b91b-20c40b1a2cd1-medium

MYSQL Command should remember

This is just to save some mysql command that sometimes I forget. The store is good for me when I need to look back and copy paste.

1. Faster import sql file

Export and Compress sql file:

Decompress and Import:

Create new user and pass:

Grant privileges:

List of the “in progress” process:

 

Install Jasig CAS in ubuntu 14.04

To install CAS, your machine has to have Tomcat. In ubuntu 14.04, you will easily install Tomcat 7 with command apt-get. It is quite simple, just concern about ssl connection

19b004fa-32bf-11e4-9354-12313b024af0-medium

 

The first step, install tomcat7 by command:

Next step, you install https for Tomcat. To do that, you need to generate key by using keytool:

Change tomcat config file:

Add content below to server.xml:

Download Jasig Cas 4.0:

Copy war file to Tomcat Web Root:

So now, restart tomcat:

Forward port 443 to port 8443:

Test:

Login CAS with default account: casuser/Mellon

Or you can add new account by editing file: /var/lib/tomcat7/webapps/cas-server-webapp-4.0.0/WEB-INF/deployerConfigContext.xml

Troubleshooting your installation:

 

Expand disk with LVM

This article will guide to expand disk with LVM. My scenario is I install linux in virtual machine VMWare. And I use VMWare to expand disk (sdb) from 80G to 160G. So now, I need to setup linux machine to use expanded disk.

At the first, check disks with fdisk

You can see in the output that /dev/sdb is 160 Gb. However, we just create a partition sdb1 (80G).

So use fdisk to add a new partition sdb2  (type Linux LVM)

Step 2, create physical volume with pvcreate:

Step 3, extend volume group:

Extend logical volume

Finally, re-size file system: