Skip to content

This project demonstrates, how to integrate gitlab api and abdkit library in a simple website application using nodejs.

License

Notifications You must be signed in to change notification settings

akarsh/GitLab-API-Implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitLab-API-Implementation

This project demonstrates, how to integrate gitlab api and abdkit library in a simple website application using nodejs.

Table of Contents

Introduction

This project was created to make it easy for the testers to download an artifact file i.e. apk file without navigating through the multiple pages in GitLab website. and it integrates the adbkit. Which allows the tester to install the artifact file i.e. apk file on all the connected devices to the computer; where this application is running.

Note: You need to initialise adb on the computer and check all the devices are connected to the computer via

$ adb devices

Note:

For more details on the gitlab library. Refer to node-gitlab

For more details on the adbkit library. Refer to adbkit

Installation

cd into folder GitLab-API-Implementation then

npm install -save

Project file structure

  • app.js - Application starting point
  • node_modules/ - Contains all the downloaded dependent node modules
  • public/ - Contains the image files, js files and css dependencies
  • package.json - Contains the dependency configuration for npm managed node modules
  • routes/ - URL(HTTP method) to controller mapping and all file paths of jade files are declared
  • views/ - Contains the view templates for the application

Tutorial

The library files are declared

var http = require('http'); // http library https://www.npmjs.com/package/http
var fs = require('fs'); // fs library https://www.npmjs.com/package/fs
var formidable = require("formidable"); // formidable library https://www.npmjs.com/package/formidable
var util = require('util'); // util library https://www.npmjs.com/package/util

// Express library for routing. Refer to documentation https://expressjs.com/en/guide/routing.html for more details.
var express = require('express'); // express library https://www.npmjs.com/package/express
var app = express();

// GitLab nodeJS library to access GitLab API
var gitlab = require('gitlab'); // gitlab library https://www.npmjs.com/package/gitlab

// Libraries for adb installation
var Promise = require('bluebird') // bluebird library https://www.npmjs.com/package/bluebird
var adb = require('adbkit') // adbkit library is a nodejs client for adb https://www.npmjs.com/package/adbkit
var request = require('request') // request library to make http calls https://www.npmjs.com/package/request
var Readable = require('stream').Readable // stream library https://www.npmjs.com/package/stream
var client = adb.createClient()

The global variables are declared

// Global variables
var storeProjectId; // Project Id
var storeProjectName; // Project Name
var storeProjectUsername; // Project username
var storeBranches = [];  //Branches
var storeBuildId = []; // Build Id
var storeBuildName = []; // Build Name
var storeBuildStatus = []; // Build Status
var storeBuildStage = []; // Build Stage
var storeBuildReference = []; // Build Reference
var storeBuildArtifacts = []; // Build Artifacts

Express library is used to do the routing

/* GET home page. */
router.get('/', function (req, res) {
  res.render('index', {
    title: 'Home'
  });
});

/* POST projects page. */
router.post('/projects', function (req, res) {
  processAllFieldsOfTheProjectsForm(req, res);
});

/* POST branches page. */
router.post('/projects/branches', function (req, res) {
  processAllFieldsOfTheBranchesForm(req, res);
});

/* POST builds page. */
router.post('/projects/branches/builds', function (req, res) {
  processAllFieldsOfTheBuildsForm(req, res);
});

/* POST trace page. */
router.post('/projects/branches/builds/trace', function (req, res) {
  processAllFieldsOfTraceForm(req, res);
});

/* POST trace page. */
router.post('/projects/branches/builds/install', function (req, res) {
  processAllFieldsOfInstallForm(req, res);
});

Note:

For tutorial on how the adbkit is used to install an apk file. Refer to adkit-install-apk-tutorial

Credits

This project uses Open Source components. You can find the source code of the open source projects along with license information below. I acknowledge the authors of the open source projects and I'm grateful for their contributions to the open source community.

About

This project demonstrates, how to integrate gitlab api and abdkit library in a simple website application using nodejs.

Topics

Resources

License

Stars

Watchers

Forks