Skip to content

Continuous Integration

Raphael Willian edited this page Jan 26, 2018 · 111 revisions

Continuous Integration

Raphael Willian, Rodrigo Avancini

Summary

Overview

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. With GitHub, the developers can integrate their changes through Pull Requests. Every time you make a new commit and send it to a Pull Request, a continuous integration server attempts to build, to test and to execute the entire product to guaranteed the changes made in pull works properly. Integrating regularly, you can detect errors quickly, and to trace ways to solve them easily.

Current implementation can be viewed at http://www.dpi.inpe.br/jenkins

Jenkins

Jenkins is a continuous integration and continuous delivery platform that increases productivity, building and running software applications continuously, providing easier project changes. Jenkins has written in Java, providing a multi-platform and a huge community support.

Terminology

  • Job is a runnable task that are handled by jenkins.
  • Build is a job execution;
  • Workspace is a current directory used by a job.
  • Node or Slave is a computer that are set up to build projects. Jenkins handles each one node distributing loads to slave.
  • Pipeline is a work-flow of a project. In Jenkins, you can set a pipeline project in order to determine each stage of continuous integration process.

Requirements

  • Jenkins - 2.2.2;
  • SSH Server (Unix Slaves communication);
  • Git;
  • .NetFramework 3.5 (Windows slave only).

Installation

Linux Ubuntu

Jenkins has a auto bash script that add repository where it has a compiled version. Open a terminal and type below commands:

$ wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
$ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins

After that, start Jenkins service:

sudo /etc/init.d/jenkins start

Mac OS

Go to Jenkins site and download stable .pkg:

Direct Link: https://jenkins.io/content/thank-you-downloading-os-x-installer/#stable

Windows

Go to Jenkins site and download stable .exe:

Direct Link: https://jenkins.io/content/thank-you-downloading-windows-installer/#stable

Test application

Open a browser and check http://localhost:8080

Plugins

Plugins aggregate extensibility providing extra features created by third-party developers. There are several plugins available for Jenkins provided by huge Jenkins community. In order to integrate with GitHub, we must install plugins described below:

  • GitHub Plugin - It integrates with GitHub API to provide a communication between Jenkins and GitHub platform. The current version installed is 2.4.4;
  • GitHub Pull Request Builder - It provides a integration with GitHub pull requests, allowing Jenkins to build pull requests and delivery a build status. The current version installed is 1.32.3;
  • Embeddable Build Status - Plugin responsible for show build status icon. The current version installed is 1.9
  • AnsiColor - Plugin that adds support ANSI escape sequences, including color to Console Output. The current version installed is 0.4.2.
  • Xvfb plugin - It emulates a graphical interface. It is necessary in order to run TerraME tests;
  • EnvInject Plugin - It enables to export variables to using in build context.
  • Publish over SSH - It enables to send files through SSH communication. It will be used to deploy TerraME installers in open domain.

Security

Jenkins has several security ways to handle and protect user configuration. By default, the Jenkins Dashboard does not have passport security, defining anonymous user as Administrator access. In this project, we are envisioning to use Matrix Responsibility View, which provides a user permission table, specifying who can build, configure even read only.

Adminstrator - Admin
Anonymous - Overall reading;

How to configure matrix of responsibility

To enable Matrix Responsibility View as default security mode in Jenkins follow below steps:

  • Go To Jenkins Dashboard and click in Manage Jenkins;
  • Click in Configure Global Security;
  • Check Enable security to true:
    • In TCP port for JNLP slave agents leave as Random;
    • Under Access Control, Security Realm, check true to Jenkins’ own user database and mark to false in Allow users to sign up if would not like to sign up new users.
    • Under Authorization, mark Matrix-based security. (be aware in the next steps). By default, Jenkins has a anonymous user that can manage everything. You must un-mark all checkboxes and check only Overall - Read. Now, you should create a root account to manage jenkins.
      • In User/group to add, fill out a new user: root;
      • Check option Administer in Overall section.
    • (Optional) In Markup Formatter, change Plain text to Raw HTML to enable Jenkins render html within job description. It may be useful for display direct property as github pull request link.
    • Save settings.

Once it configured, you will be redirected to login page. Fill out user and Jenkins will redirect to dashboard to you type a password.

Reset security

If you are setting Jenkins security and an exception occurs, Jenkins may lock you out. That is, you will not able to log in. To reset Jenkins security you need go to $JENKINS_HOME (/var/lib/jenkins) and follow that commands:

  • Edit config.xml in $JENKINS_HOME
  • Remove all elements authorizationStrategy and securityRealm;
  • In <useSecurity>true</useSecurity>, replace true to false.
  • Restart Jenkins: sudo service jenkins restart

See more in Jenkins Disable Security

GitHub

Jenkins uses GitHub API to authenticate through OAUTH concept to handle incomming operations of GitHub integration. In this way, a account is required to use this concept and to trigger build process in continuous integration server. The account should have a personal access token with specific features to trigger each one of builds and builds responses. With this purpose, we will create a GitHub account called terrame-bot to build and to delivery GitHub pull request status.

  • Create a new Github account: terrame-bot.
  • Add this new user to the repository with admin privilege;
  • Log in with new account and go to settings;
  • Create a new personal access token:
    • Give a name of token and check: repo, admin:org, admin:public_key, admin:repo_hook
    • Copy the generated token and go to Jenkins Dashboard;
  • Go to Jenkins Dashboard and click in Credentials and again in Global Credentials (unrestricted);
  • Click in Add credentials e fill out the form:
    • In Kind, select Secret Text;
    • In Secret, paste the generated token;
    • In Description, type a description of key: TerraME Bot Jenkins Token and confirm.
    • Save settings.
  • Go To Jenkins Dashboard and click Manage Jenkins and then Configure System;
  • Under GitHub section (Check if does not exists same configuration created before):
    • click in Add new GitHub Server;
    • Fill out API URL as https://api.github.com;
    • Select credentials created before (step 8).
    • Mark Manage hooks and click in Test connection to check if connection is valid.
  • Under GitHub Pull Request Builder:
    • Click in Add to create new server configuration. This is a global configuration that determines how to connect in GitHub API through this plugin.
    • In GitHub Server API URL, fill out https://api.github.com;
    • In Credentials, select the credential created before (Step 8);
    • You can validate connection, clicking in Test Credential, marking Test basic connection to GitHub and then Connect to API.
    • Add description of global integration. i.e: Jenkins - TerraME
    • Save settings.

Now, we must configure a URL for Jenkins receive GitHub requests. Whenever a change is made in repository, GitHub can send change details via HTTP POST method.

Nodes

Creating new node for Linux and Mac OSX environments

Requirement SSH Server and Java JRE (7 or higher)

As Linux and Mac OSX are Unix-based, they handled by a SSH connection, turning out a easily integration with Jenkins.

  • Go to Jenkins Dashboard and click in Manage Jenkins;
  • Click in Manage Nodes and click New Node;
  • Type a name as slave-ubuntu-14.04 and select Dumb Slave.
  • In Label type ubuntu-16.04-terrame;
  • Insert a number of executors - Number of jobs jenkins can perform;
  • Set remote repository folders (folder where sources code can be found):
    • /home/jenkins/build-projects for Linux environment;
    • /Users/jenkins/MyDevel/build-ci for Mac OSX environment
  • Give a host and credential. Jenkins connects via SSH, and confirm.

Creating new node for Windows environment

As Windows does not provide a native SSH connection. The Jenkins developers recommend to use Java Communication since it works properly than third parties SSH software. Make sure you have java >= 7 installed. In order to configure, follow the below steps:

  • Go to Jenkins Dashboard and click in Manage Jenkins;
  • Click in Manage Nodes and click New Node;
  • Type a name as slave-windows-10 and select Dumb Slave.
  • Insert a number of executors: 2;
  • Set remote repository folders: C:\MyBuilds;
  • In Label type windows-10;
  • In Launch Method, select Launch agent via Java Web Start:
    • Click in Advanced and select Tunnel connection through with Windows Machine IP
  • Save settings.

After that, we must access Windows machine, go to Jenkins Dashboard and Download the java-agent.jar available in Nodes page. Once downloaded, execute it and click in Install as a Windows Service.

Jobs

To make Jenkins working with TerraME for building and running application tests, we should separate them into specific jobs or Pipeline stages:

It will provides to GitHub a easily way for representing jenkins feedback’s. Before jobs creation, we adopted a pattern for job name in order to group and to identify easily. The pattern is terrame-task-environment, where:

  • environment represents which Operational System will execute: linux-ubuntu-14.04, mac-el-captain, windows-10;
  • task Represents what will execute: build, unittest, test-execution, doc etc.

Each job contains a manual configuration for GitHub Integration defined in bash (except first job - TerraME TerraLib Compilation). It was required since Jenkins GitHub Pull Request Plugin does not support TerraME requirements status handler. In order to customize GitHub Status Notification Name, you must change value from GITHUB_CONTEXT variable.

  • TODO: about CI, Daily and Packages (Views)
  • Add in job the step for create in correct view

Follow below commands to create the TerraME jobs:

TerraLib

TODO(#1895): not reviewed

  • Go to dashboard and click in Create Item;
  • Type a name terrame-terralib-build-enviroment;
  • Select Free-style project;
  • Fill out GitHub project with https://github.com/TerraME/terrame.
  • In Restrict where this project can be run, select:
    • ubuntu-14.04-terrame-reader for GitHub CI. It is important since everybody can open a GitHub PR. In this way, they may inject scripts that turn out security problems. Therefore, we created read-only user for GitHub PR named as reader
    • ubuntu-14.04-terrame for daily execution.
  • In Source Code Management, mark Git option and add repository https://github.com/TerraME/terrame.git. It is not necessary select a credential if you are using https.
    • In Branch Specifier (blank for 'any'), type ${ghprbActualCommit}. It tells to Jenkins to check latest commit from git tree.
    • In Advanced button:
  • In Build Triggers, mark GitHub Pull Request Builder:
    • In GitHub API credentials, select the credential created before and confirm;
    • Click in Advanced:
      • Check Use github hooks for build triggering to true;
      • Check Build every pull request automatically without asking to true.
    • Click in Trigger Setup and select Update commit status during build.
    • In Commit Status Context defines:
      • Title: Linux TerraLib Compilation;
      • Build Url: $BUILD_URL/consoleFull
  • In Build Environment, select Inject environment variables to the build process and in Properties Content type:
_TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
_TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
_TERRALIB_3RDPARTY_DIR=/home/jenkins/MyDevel/terrame/ci/3rdparty/5.2
_TERRALIB_INSTALL_PATH=$_TERRALIB_BUILD_BASE/solution/install
_TERRALIB_MODULES_DIR=$_TERRALIB_INSTALL_PATH
_TERRALIB_OUT_DIR=$_TERRALIB_BUILD_BASE/solution/build
_TERRALIB_GIT_DIR=$_TERRALIB_BUILD_BASE/git
_TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
_TERRAME_DEPENDS_DIR=/home/jenkins/MyDevel/terrame/daily/terrame/3rdparty/install
_TERRAME_OUT_DIR=$_TERRAME_BUILD_BASE/solution/build
_TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
_TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
_TERRAME_REPOSITORY_DIR=$_TERRAME_BUILD_BASE/repository
_TERRAME_EXECUTION_DIR=$_TERRAME_BUILD_BASE/test
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:
cd jenkins/linux
./terrame-terralib-build-linux-ubuntu-14.04.sh
  • In Post build actions:
    • Configure Trigger parameterized builds on other projects with the following statements.
      • In Projects to build, type terrame-syntaxcheck-cpp-environment;
      • In Trigger when build is, select Stable TerraME is not able to run any test without a built directory.
      • Click in Add parameters and select Predefined.

Note Once you configured Jenkins for building Pull Requests, the option Build Now in interface will not work since it depends JSON sent by GitHub.

Syntax and semantics check

TODO(#1895): not reviewed

  • Go to Dashboard and click in New Item:

    • Give a name of job: terrame-syntaxcheck-cpp-linux-ubuntu-14.04;
    • Select Free-style project;
    • In Restrict where this project can be run, select:
      • ubuntu-14.04-terrame-reader for GitHub CI;
      • ubuntu-14.04-terrame for daily execution.
  • In Build Steps section, click in Add build step and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="C++ Syntax"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "" "$BUILD_URL/consoleFull" "Code inspection running."
    cd jenkins/linux
    ./terrame-syntaxcheck-cpp-linux-ubuntu-14.04.sh
    RESULT=$?  # Retrieving Script Execution Exit Code
    
    # Identifying Execution Status Alias name
    if [ $RESULT -eq 0 ]; then
      GITHUB_DESCRIPTION="Build successfully"
      GITHUB_STATUS="success"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="Build failure"
    fi
    
    # Reporting Job execution to GitHub
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    
    exit $RESULT # Finishing Job execution with correct status
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-syntaxcheck-cpp-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects in order to trigger job terrame-build passing current commit hash (to build terrame on isolate directory) and Pull request RefSpec to fetch changes.
      • In Projects to build, type terrame-build-ENVIROMENT;
      • In Trigger when build is, select Complete (Always) since code analysis does not affect build condition;
      • Click in Add parameters and select Predefined. It is only required because a job must contain at least a block parameters, otherwise it wont work properly.
    • Configure to Jenkins send email from build result code. The recipients will receive a direct link to Build Status in Jenkins Dashboard (Optional).
      • Select E-mail Notification in Add post-build actions;
      • Type recipients: terrame.bot@gmail.com (Use white-space separator for extra receivers).
      • Mark true the Send e-mail for every unstable build
  • Save settings

  • Configure upstream job that will trigger current job. Go to TerraLib Build, and in Post build actions, add terrame-syntaxcheck-cpp-linux-ubuntu-14.04 in Projects to build

TerraME Build

TODO(#1895): not reviewed

A TerraME build must run after Syntax Check CPP independent of build status since it is static analyze.

  • Go to dashboard and click in Create Item;
  • Type a name _terrame-build-enviroment;
  • Fill out GitHub project with https://github.com/terrame/terrame;
  • In Restrict where this project can be run, select:
    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment, select Inject environment variables to the build process and in Properties Content type:
_ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
_TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
_TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
_TERRALIB_3RDPARTY_DIR=/home/jenkins/MyDevel/terrame/ci/3rdparty/5.2
_TERRALIB_INSTALL_PATH=$_TERRALIB_BUILD_BASE/solution/install
_TERRALIB_MODULES_DIR=$_TERRALIB_INSTALL_PATH
_TERRALIB_OUT_DIR=$_TERRALIB_BUILD_BASE/solution/build
_TERRALIB_GIT_DIR=$_TERRALIB_BUILD_BASE/git
_TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
_TERRAME_DEPENDS_DIR=/home/jenkins/MyDevel/terrame/daily/terrame/3rdparty/install
_TERRAME_OUT_DIR=$_TERRAME_BUILD_BASE/solution/build
_TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
_TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
_TERRAME_REPOSITORY_DIR=$_TERRAME_BUILD_BASE/repository
_TERRAME_EXECUTION_DIR=$_TERRAME_BUILD_BASE/test
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Linux Compilation"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$BUILD_URL" "Build running."
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-build-linux-ubuntu-14.04.sh
    
    RESULT=$?
    # Identifying Execution Status Alias name
    if [ $RESULT -eq 0 ]; then
      GITHUB_DESCRIPTION="Build successfully"
      GITHUB_STATUS="success"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="Build failure"
    fi
    
    /home/jenkins/Configs/terrame/status/send.sh ${ghprbActualCommit} "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-build-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-code-analysis-base|terralib-ENVIROMENT;
      • In Trigger when build is, select Stable;
      • Click in Add parameters and select Predefined using following script:
  • Configure upstream job that will trigger current job. Go to Syntax Check CPP, and in Post build actions, add terrame-build-linux-ubuntu-14.04 in Projects to build

Code Analysis of Package Base

TODO(#1895): not reviewed

A TerraME Code Analysis Base runs after TerraME Build only if build succeeds.

  • Go to dashboard and click in Create Item;

  • Type a name _terrame-code-analysis-base-enviroment;

  • Select Free-style project;

  • In Restrict where this project can be run, select:

    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment,

    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 5 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Code analysis of package base"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-code-analysis-linux-ubuntu-14.04.sh
    
    RESULT=$?
    
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Code analysis executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-code-analysis-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-code-analysis-terralib-ENVIROMENT*;
      • In Trigger when build is, select Complete (Always);
      • Click in Add parameters and select Predefined
  • Configure upstream job that will trigger current job. Go to TerraME Build, and in Post build actions, add terrame-code-analysis-base-linux-ubuntu-14.04 in Projects to build

Code Analysis of Package GIS

A TerraME Code Analysis GIS runs after Code analysis of package base independent of build status result.

  • Select the View (CI or Daily)

  • Go to dashboard and click in Create Item;

  • Type a name terrame-code-analysis-gis-enviroment;

  • Select Free-style project;

  • In General,

  • Check GitHub project and type https://github.com/TerraME/terrame.git/

  • Restrict where this project can be run, type:

    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:

    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 6 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • Select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Code analysis of package gis"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-code-analysis-linux-ubuntu-14.04.sh "gis"
    
    RESULT=$?
    
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Code analysis executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-code-analysis-linux-ubuntu-14.04.sh "gis"
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-doc-base-*-ENVIROMENT;
      • In Trigger when build is, select Complete (Always);
      • Click in Add parameters, select Predefined and type:
  ghprbActualCommit=$ghprbActualCommit
  • Save the project in current View

  • Configure upstream job that will trigger current job. Go to Code Analysis of Package Base, and in Post build actions, add terrame-code-analysis-gis-linux-ubuntu-14.04 in Projects to build

Documentation of package base

A TerraME Documentation of base runs after Code Analysis of Package TerraLib independent of build status.

  • Go to dashboard and click in Create Item;

  • Type a name _terrame-doc-base-enviroment;

  • Select Free-style project;

  • In Restrict where this project can be run, select:

    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:

    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 7 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Documentation of package base"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL/consoleFull" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-doc-linux-ubuntu-14.04.sh
    
    RESULT=$?
    
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Tests executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-doc-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-unittest-base-ENVIROMENT*;
      • In Trigger when build is, select Complete (Always);
      • Click in Add parameters and select Predefined
  • Configure upstream job that will trigger current job. Go to Code Analysis of Package TerraLib, and in Post build actions, add terrame-doc-base-linux-ubuntu-14.04 in Projects to build

Documentation of package GIS

A TerraME Documentation of GIS runs after Documentation of package base independent of build status.

  • Select the View (CI or Daily)

  • Go to dashboard and click in Create Item;

  • Type a name terrame-doc-gis-enviroment;

  • Select Free-style project;

  • In General

  • Restrict where this project can be run, type:

    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:

    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 8 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • Select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Documentation of package gis"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL/consoleFull" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-doc-linux-ubuntu-14.04.sh "gis"
    
    RESULT=$?
    
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Tests executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-doc-linux-ubuntu-14.04.sh "gis"
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-unittest-base-ENVIROMENT*;
      • In Trigger when build is, select Complete (Always);
      • Click in Add parameters, select Predefined and type:
  ghprbActualCommit=$ghprbActualCommit
  • Save the project in current View

  • Configure upstream job that will trigger current job. Go to Documentation of package Base, and in Post build actions, add terrame-doc-gis-linux-ubuntu-14.04 in Projects to build

Functional test of package base

A TerraME Functional Test of package base must run only if builds succeed. Otherwise, jenkins will not be able to call terrame executable.

  • Go to dashboard and click in Create Item;

  • Type a name _terrame-unittest-base-enviroment;

  • Select Free-style project;

  • In Restrict where this project can be run, select:

    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:

    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 9 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:

    • For CI, use following statements:
    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Functional test of package base"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL/consoleFull" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-unittest-linux-ubuntu-14.04.sh
    
    RESULT=$?
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Tests executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-unittest-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-unittest-terralib-ENVIROMENT*;
      • In Trigger when build is, select Complete (Always);
      • Click in Add parameters and select Predefined
  • Configure upstream job that will trigger current job. Go to Documentation of package TerraLib, and in Post build actions, add terrame-unittest-base-linux-ubuntu-14.04 in Projects to build

Functional test of package GIS

A TerraME Functional Test of package GIS after Functional Test of package Base independent of build status.

  • Select the View (CI or Daily)
  • Go to dashboard and click in Create Item;
  • Type a name terrame-unittest-terralib-enviroment;
  • Select Free-style project;
  • In General
  • Restrict where this project can be run, select:
    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:
    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 10 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • Select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:
  • For CI, use following statements:

    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Functional test of package gis"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL/consoleFull" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-unittest-linux-ubuntu-14.04.sh "gis"
    
    RESULT=$?
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Tests executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-unittest-linux-ubuntu-14.04.sh "gis"
  • In Build Steps add Send files or execute commands over SSH

    • In Name select Jenkins Slave Linux (Public) [No Exec]
    • In Tranfers
      • In Sources files type build*.tar.gz
      • In Remote directory type Public/terrame/logs/gis
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-test-execution-ENVIROMENT*;
      • In Trigger when build is, select Complete (Always);
      • Click in Add parameters, select Predefined and type:
  ghprbActualCommit=$ghprbActualCommit
  • Save the project in current View

  • Configure upstream job that will trigger current job. Go to Functional test of package base, and in Post build actions, add terrame-unittest-gis-linux-ubuntu-14.04 in Projects to build

Execution test

A TerraME Functional Execution Test must run after unittests, independent of build status.

  • Go to dashboard and click in Create Item;
  • Type a name _terrame-test-execution-terralib-enviroment;
  • Select Free-style project;
  • In Restrict where this project can be run, select:
    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:
    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 11 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • Select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_EXECUTION_DIR=$_TERRAME_BUILD_BASE/test
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:
  • For CI, use following statements:

    set +e # Force to shell do not close immediately on error execution. You must end with "exit SOME_INT_CODE"
    
    GITHUB_CONTEXT="Test Execution"  # GitHub Status Name
    
    # Notify GitHub with job started execution
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "pending" "$BUILD_URL/consoleFull" "Running."
    
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-test-execution-linux-ubuntu-14.04.sh
    
    RESULT=$?
    if [ $RESULT -eq 0 ]; then
      GITHUB_STATUS="success"
      GITHUB_DESCRIPTION="Tests executed successfully"
    elif [ $RESULT -eq 255 ]; then
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT or more errors found"
    else
      GITHUB_STATUS="failure"
      GITHUB_DESCRIPTION="$RESULT tests failed"
    fi
    /home/jenkins/Configs/terrame/status/send.sh $ghprbActualCommit "$GITHUB_CONTEXT" "$GITHUB_STATUS" "$BUILD_URL/consoleFull" "$GITHUB_DESCRIPTION"
    exit $RESULT
    • For daily execution:
    cd $_TERRAME_GIT_DIR/jenkins/linux
    ./terrame-test-execution-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-repository-test-ENVIROMENT*;
      • In Trigger when build is, select Stable;
      • Click in Add parameters and select Predefined
  • Configure upstream job that will trigger current job. Go to Functional test of package TerraLib, and in Post build actions, add terrame-test-execution-linux-ubuntu-14.04 in Projects to build

Repository test (only daily)

The TerraME repository test must not be integrated with GitHub.

  • Go to dashboard and click in Create Item;
  • Type a name _terrame-repository-test-terralib-enviroment;
  • Select Free-style project;
  • In Restrict where this project can be run, select:
    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • In Build Environment:
    • Check Start Xvfb before the build, and shut it down after.:

      • In Xvfb installation, use Xvfb for Linux Environment and MacOSCapitan for MacOSX El Capitan node;
        • In Xvfb specific display name, type an unique identifier along jobs: 12 for example;
        • In Xvfb display name offset, type an offset value. (Prefer max 3 to allow Xvfb switch display numbers);
    • Check the option Color ANSI Console Output to enable terminal color output:

      • In ANSI color map, select xterm.
    • Select Inject environment variables to the build process and in Properties Content type:

    _ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
    _TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
    _TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
    _TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
    _TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
    _TERRAME_REPOSITORY_DIR=$_TERRAME_BUILD_BASE/repository
  • In Build Steps add Add step to condition and select Execute Shell and paste below commands in text area:
cd $_TERRAME_GIT_DIR/jenkins/linux
./terrame-repository-test-linux-ubuntu-14.04.sh
  • In Post build actions:

    • Configure Trigger parameterized builds on other projects with following statement.
      • In Projects to build, type terrame-installer-ENVIROMENT*;
      • In Trigger when build is, select Stable;
      • Click in Add parameters and select Predefined
  • Configure upstream job that will trigger current job. Go to Execution Test, and in Post build actions, add terrame-repository-test-linux-ubuntu-14.04 in Projects to build

Installer (only daily)

After TerraME workflow execution (build/doc and test). You must generate a installer of source code and provide to user. Currently, the daily installers are available in TerraME Installers

  • Go to dashboard and click in Create Item;
  • Type a name _terrame-installer-enviroment;
  • Select Free-style project;
  • In Restrict where this project can be run, select:
    • ubuntu-14.04-terrame-reader for GitHub CI;
    • ubuntu-14.04-terrame for daily execution.
  • Fill out GitHub project with https://github.com/terrame/terrame;
  • In Build Environment, select Inject environment variables to the build process and in Properties Content type:
_ROOT_BUILD_DIR=$HOME/MyDevel/terrame/ci
_TERRALIB_BUILD_BASE=$_ROOT_BUILD_DIR/terralib
_TERRAME_BUILD_BASE=$_ROOT_BUILD_DIR/terrame
_TERRALIB_3RDPARTY_DIR=/home/jenkins/MyDevel/terrame/ci/3rdparty/5.2
_TERRALIB_INSTALL_PATH=$_TERRALIB_BUILD_BASE/solution/install
_TERRALIB_MODULES_DIR=$_TERRALIB_INSTALL_PATH
_TERRALIB_OUT_DIR=$_TERRALIB_BUILD_BASE/solution/build
_TERRALIB_GIT_DIR=$_TERRALIB_BUILD_BASE/git
_TERRAME_GIT_DIR=$_TERRAME_BUILD_BASE/git
_TERRAME_DEPENDS_DIR=/home/jenkins/MyDevel/terrame/daily/terrame/3rdparty/install
_TERRAME_OUT_DIR=$_TERRAME_BUILD_BASE/solution/build
_TERRAME_INSTALL_PATH=$_TERRAME_BUILD_BASE/solution/install
_TERRAME_TEST_DIR=$_TERRAME_BUILD_BASE/utest
_TERRAME_REPOSITORY_DIR=$_TERRAME_BUILD_BASE/repository
_TERRAME_EXECUTION_DIR=$_TERRAME_BUILD_BASE/test
  • In Build Environment, select Inject environment variables to the build process and in Properties Content type:
cd $_TERRAME_GIT_DIR/jenkins/linux
./terrame-installer-linux-ubuntu-14.04.sh
  • Configure upstream job that will trigger current job. Go to Repository Test, and in Post build actions, add terrame-repository-test-linux-ubuntu-14.04 in Projects to build

Demonstration

TerraME CI Integration

The currently implementation is running only on Linux Environments due hardware resources limitation. The other machines windows and mac does not have much computational resources turning out impractical implementation in Pull Request Continuous integration. Note that Repository Tests is not tested in Continuous Integration since it is slow. It is usually executed in daily builds.

Task Linux
dependencies
cpp-check
compile
base-check
base-test
base-doc
gis-check
gis-test
gis-doc
execution-test

Daily builds

The daily builds represents the same build type executed on multiple operational systems. It is necessary in order to guaranteed software stability on different environments due TerraME is cross-platform. It was scheduled on 02:00 PM. A installer is created after TerraME tests execution. The installer can be downloaded from http://www.dpi.inpe.br/jenkins-data/terrame/installers/· Basically, they are different jobs with similar configuration, except with setting file (test.lua) that contains extra options like examples = true, time = true and so on that requires additional time in execution.

Task Windows Linux Mac
dependencies
cpp-check
compile
base-check
gis-check
base-doc
gis-doc
base-test
gis-test
execution-test
repository-test
installer

Note that some build tasks is not required for all environments due it represents only a code inspection

TerraME CI Packages

The currently implementation is running only on Linux Environments due same reasons as TerraME CI. The packages are tested using last TerraME daily build. Jenkins only performs:

  • Code inspection;
  • Doc generation;
  • Unittest.
Package check doc test
ca
calibration
gpm
logo
publish
rstats
sci
sysdyn

Extra tools

Cpplint

Cpplint is an automated checker to make sure C++ files follows Google's C++ style guide. Google Style Guide. See more in Official Google Style guide Cpplint

Installation

In order to install cpplint is too simple. Just clone repository.

git clone https://github.com/google/styleguide.git
cd styleguide/cpplint

Configuration

Modifying to retrieve errors

In cpplint.py, look for:

sys.exit(_cpplint_state.error_count > 0)

Replace to:

sys.exit(_cpplint_state.error_count if _cpplint_state.error_count < 255 else 255)

Bash scripts

GitHub Statuses Notification

It notifies GitHub interface with Build Job information. (Jenkins will generate this mock with respective token configured in GUI credential). For security reasons, we skip ACCESS_TOKEN code.

Usage: ./send.sh COMMIT_HASH STATUS_CONTEXT STATUS JOB_URL STATUS_DESCRIPTION

  • COMMIT_HASH - Represents a GitHub Pull Request commit sha1;
  • STATUS_CONTEXT - Represents GitHub Status Name. It will be shown on GitHub PRs.
  • JOB_URL - Represents Jenkins Build URL. When pass this parameter, use $BUILD_URL.
  • STATUS_DESCRIPTION - Represents a extra description of Status.
#!/bin/bash

# usage: ./send.sh COMMIT_HASH STATUS_CONTEXT STATUS JOB_URL STATUS_DESCRIPTION

# Github initial status
GITHUB_STATUS="$3"
# GitHub current commit
GITHUB_COMMIT=$1
# GitHub description status
GITHUB_DESCRIPTION=$5
# Status Context: The display name
GITHUB_CONTEXT=$2
# Current Jenkins URL
JENKINS_URL=$4
# TerraME Bot Token
ACCESS_TOKEN="PutPrivateTokenHere"

JSON="{\"state\": \"$GITHUB_STATUS\", \"target_url\": \"$JENKINS_URL\", \"description\": \"$GITHUB_DESCRIPTION\", \"context\": \"$GITHUB_CONTEXT\"}"

# A common function to notify GitHub
function request() {
  curl --silent -H "Content-Type: application/json" -X POST -d "$1" https://api.github.com/repos/terrame/terrame/statuses/$2?access_token=$3 > /dev/null
}
# Sending Request
request "$JSON" "$GITHUB_COMMIT" "$ACCESS_TOKEN"