Continuous Integration

Introduction


Integrate and synchronize with 3rd party providers that offers the ability to run automated build and ensure continuous integration.

When you integrate with Continuous Integration ( CI ) Providers, they begin to monitory activies on your repository.

Whenever there is a code modification ( developers push new code changes ), based on the configuration you provide per repo, the provider pulls a copy of your repo and attempts to run an automated build.

The automated build is dictated via a recipe that each provider requires you provided it with. The recipe contains instructions on what should be installed and how to run the build as well as how to identify if the build ran successfully or if it failed.

You can learn more about Continuous Integration via this Link.



Objective


  1. List all CI providers supported by SOAJS
  2. Set up a CI recipe or update it
  3. CI/CD Full Horizontal Flow



 Create a CI recipe


Head to Develop pillar → Continuous Integration Accounts tab. You will find 4 different CI providers supported by SOAJS : Travis CI - Drone - Jenkins - TeamCity.

Pick the provider you would like to integrate with.

Enter you GIT Token and press submit. To get a GIT Token, you should visit your git account in the settings page and generate one. Choose wisely the repositories you have access to them.

Head to Recipes tab → Click Add New Recipe → Choose between existing or a blank template → Enter a unique recipe name → Enter the CI recipe content and submit.

Step 1

Step 2

Step 3

Make sure you have an account on the CI provider you have chosen that has access to your git account


Update a CI recipe


Head Develop pillar → Continuous Integration → Recipes tab.

You can view or edit any recipe content. You can delete any custom recipe as well.

If you want to change the provider, click on Deactivate button in Accounts tab to start from scratch. 



CI/CD Full Horizontal Flow


Once CI/CD is configured and the files are in the repository, once a developer pushes updates to the master branch of this repo, the following scenario will take place:

1

Travis will pick up the change, and run the build operation as instructed by the Yaml Configuration of CI

2

Once the build is done and successful

1Travis will execute the soajs.cd.js script that was supplied as per CD
2

Travis will Construct a request to the "deploy" API of SOAJS Dashboard from the environment variables that were configured under CI

3Travis will fire the request and provide him with the repo name and branch
Triggering CD deploy API
{
  //"uri": "http://dashboard-api.soajs.org:80/cd/deploy?deploy_token=yyyyyyyyyyy"
  "uri": "$SOAJS_CD_DASHBOARD_PROTOCOL://$SOAJS_CD_DASHBOARD_DOMAIN:$SOAJS_CD_DASHBOARD_PORT$SOAJS_CD_DASHBOARD_ROUTE?deploy_token=$SOAJS_CD_DEPLOY_TOKEN",
  "headers": {
    "key": "$SOAJS_CD_AUTH_KEY",
    "Content-Type": "application/json"
  },
  "json": true,
  "body": {
	"repo": "soajs.nodejs.express", //repo name
    "branch": "master", //repo branch


	//if repo is a service or a multi service, the below get appended to the body
    "services": [
      {
        "serviceName": "express", 	//detected repo service
        "serviceVersion": 1			//detected service version
      }
    ]
  }
}
3

The API will load all the deployed services that match the repo name and branch

4

Then based on the CD configuration

1If the strategy is Notify, then the API will insert a new update notification received in the ledger only
2If the strategy is Update, then the API will update all affected services and insert for each one of them an auto update notification entry in the ledger