https://github.com/schultyy/ci.js
My custom continuous integration server
https://github.com/schultyy/ci.js
Last synced: about 1 year ago
JSON representation
My custom continuous integration server
- Host: GitHub
- URL: https://github.com/schultyy/ci.js
- Owner: schultyy
- Created: 2013-03-23T23:18:21.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-04-10T16:36:16.000Z (about 13 years ago)
- Last Synced: 2025-04-06T23:35:28.326Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 253 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ci.js
This is a very very basic continuous integration server written in JavaScript. This runs on node.js.
## How does it work?
It comes up with a basic http server that provides a web page where you can see the 10 latest build results.
In background, every n minutes a new build starts. After the build finished, a build result log file is written and
can be viewed on the web page.
The build server gets its work via a task file, which is plain JavaScript.
## Configuration
You need to place a file called 'options.json' in the same directory where main.js exists. The options file must contain
the following parts:
```JavaScript
{
"buildResultsFolder" : "/home/foo/bar/BuildResults",
"port" : 8080,
"host" : "127.0.0.1",
"buildInterval" : 15
}
```
Note that buildInterval expresses the interval in minutes. The build results folder must exist, ci.js does not create it.
## Usage
```Bash
$ node main.js tasks.js
```
## Task file
A task file must export a function that is called getTasks. getTasks returns one task, that calls other tasks via
callbacks when it is finished. A task must have a run method. This will be called by ci.js.
(Disclaimer: I need this to build my .Net software. So the example below contains Windows paths and calls to MSBuild.)
This is an example task file:
```JavaScript
var child_process = require("child_process");
var fs = require("fs");
exports.getTasks = function(options){
//At the moment, options contains a finshed callback and a logger
var finishedCallback = options.finished;
/*
Available methods:
error(name, msg)
info(name, msg)
*/
var logger = options.logger;
var checkout = new checkoutTask();
var buildTask = new buildTask();
checkout.callback = buildTask;
//Notify ci.js when build is finished
buildTask.callback = {
this.run = finishedCallback;
this.callback = undefined;
};
return {
name : "Your project",
projectPath : "C:\\Temp\\",
tasks : checkout
};
}
function checkoutTask(logger){
this.logger = logger;
this.callback = undefined;
this.run = function(){
console.log("checkout");
var workingDirectory = 'C:\\temp\\';
var self = this;
child_process.exec('"C:\\Program Files (x86)\\Git\\bin\\sh.exe" --login -i -c "git clone "',
{'cwd' : workingDirectory}, function(error, stdout, stderr){
if(stdout){
self.logger.info("checkout", stdout);
}
if(stderr){
self.logger.error("checkout", stderr);
}
if(error){
self.logger.error("checkout", error.signal);
self.logger.error("checkout", error.code);
return;
}
if(self.callback){
self.callback.run();
}
});
};
}
function buildTask(logger){
this.callback = undefined;
this.logger = logger;
this.run = function(){
console.log("build");
var solutionFile = "C:\\temp\\\\.sln";
var self = this;
child_process.exec('cmd.exe /s /c "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe /p:Configuration=Release ' + solutionFile + '"',
function(error, stdout, stderr){
if(stdout){
self.logger.info("build", stdout);
}
if(stderr){
self.logger.error("build", stderr);
}
if(error){
self.logger.error("build", "Signal: " + error.signal + " / Code: " + error.code);
return;
}
if(self.callback){
self.callback.run();
}
});
};
}
```
# Dependencies
* bootstrap
* JQuery 1.9.1