This project demonstrates, how to integrate gitlab api and abdkit library in a simple website application using nodejs.
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
cd into folder GitLab-API-Implementation
then
npm install -save
app.js
- Application starting pointnode_modules/
- Contains all the downloaded dependent node modulespublic/
- Contains the image files, js files and css dependenciespackage.json
- Contains the dependency configuration for npm managed node modulesroutes/
- URL(HTTP method) to controller mapping and all file paths of jade files are declaredviews/
- Contains the view templates for the application
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
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.
-
Project: express
Author: 209+ contributors
License: MIT
-
Project: node-formidable
Author: 58 contributors
License: MIT
-
Project: node-gitlab
Author: 41 contributors
License: MIT
-
Project: node-util
Author: 3 contributors
License: MIT
-
Project: bluebird
Author: 185 contributors
License: MIT
-
Project: adbkit
Author: 9 contributors
License: Apache-2.0
-
Project: request
Author: 273 contributors
License: Apache-2.0
-
Project: stream
Author: 3 contributors
License: MIT
-
Project: axios
Author: 110 contributors
License: MIT