Base64 on terminal

Encode a string

$ echo -n 'Softwaretester.info' | openssl base64 -e

The -n after the echo command, prevents echo from appending a newline character on the end of the string.

Decode a string

$ echo 'U29mdHdhcmV0ZXN0ZXIuaW5mbw==' | openssl base64 -d

Encode content of file

$ openssl base64 -e -in example.txt -out example.b64

Embed SLOCCount into Jenkins jobs

Preparation

Install SLOCCount and cloc on system.

$ aptitude install sloccount cloc

Search and install the “SLOCCount Plugin”.

jenkins sloccount plugin
Search SLOCCount Plugin

Configure

Now search your job and start configuration and insert the command “Build > Execute Shell”.

sloccount --duplicates --wide --details ${WORKSPACE}/<file|folder> > sloccount_report.sc

As last step add the Post-Build-Action – “View SLOCCount results” and insert the generated report “sloccount_report.sc”.

sloccount result path
Configure Post-Build-Action

The plugin just show the number of lines per file, file type and folder. No estimated project value or other informations! This information you can see direct on generated report. After running the build, your screen should look similar like this:

sloccount report
SLOCCount report

Markup validation with Jenkins

Preparation

Search and install the “Unicorn Validation Plugin” and “Plot Plugin”

jenkins unicorn plugin
Search for Plugin

Configure

Within the build section, add a build step “Unicorn Validator”. For the Site to validate add a URL to a site that you want to test. Before you configure the Post-build Actions you should save and run. After 1st run the workspace should look similar.

unicorn results
Workspace files

Now start configuration again. On Post-build Actions section add “Plot build data”, and add the following details:

unicorn configuration
Plot configuration

Now you can run the build again and on job navigation you see the item “Plots”. Repeat the last step for plotting of css results. As value for “Plot title” use “CSS Validation errors” and for “Data series file” use “css3-validator_errors.properties”.

Agile view for Jenkins

Preparation

Search and install the “Radiator View” plugin.

radiator plugin jenkins
Select Radiator View Plugin

Configuration

After installation create a new view, similar to configuring the more conventional list views.

radiator view jenkins
Select Radiator view

Now select all desired jobs and press “Save” button.

radiator agil view
Agile view

The build radiator view displays a box for each build with the job name and some other details, depending on build steps and test methods.

Backup and restore Jenkins

Preparation

Create a new folder with read/write permission for Jenkins.

Example

# create directory
$ mkdir backup_jenkins

# change user
$ chown jenkins:jenkins backup_jenkins/

Now install the Jenkins Plugin “ThinBackup”.

thinbackup plugin for jenkins

Backup configuration

After installation and restart, you can start with backup configuration “Manage Jenkins > ThinBackup > Settings”. For Backup directory insert the path for directory that you created. Complete the configuration by your needs and press “Save” button.

thinbackup settings

Backup

Now you could wait for 1st automated backup or press the “Backup Now” button “Manage Jenkins > ThinBackup”.

Restore

For restore simply select Restore “Manage Jenkins > ThinBackup”. Select backup from list and press “Restore” button.

RATS

RATS – Rough Auditing Tool for Security. Open-Source software to scan C, C++, Perl, PHP and Python code. For other languages see Fortify.

Installation

# CentOS
$ yum install rats

# Debian
$ aptitude install rats

# wget
$ wget http://www.fortify.com/servlet/download/public/rats-2.3.tar.gz 

# curl
$ curl --remote-name http://www.fortify.com/servlet/download/public/rats-2.3.tar.gz

# extract
$ tar xfz rats-2.3.tar.gz

# change directory
$ cd rats-2.3

# compile
$ ./configure && make && sudo make install

Execute RATS

# Simple run
$ rats --resultsonly <directory>

# Advanced run
$ rats --quiet --xml -w 3 <directory>