Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

write build.prop for jenkins tasks

  • Loading branch information...
commit a3522f07b5a159925580ba719c194c9259b997bf 1 parent 34f973f
@jasonsanjose jasonsanjose authored
Showing with 70 additions and 2 deletions.
  1. +3 −0  .gitignore
  2. +2 −1  package.json
  3. +2 −1  src/config.json
  4. +63 −0 tasks/build.js
View
3  .gitignore
@@ -2,6 +2,9 @@ Thumbs.db
src/brackets.css
src/brackets.min.css
+# ignore jenkins build info
+/build.prop
+
# ignore node_modules created by grunt, but not more deeply-nested node_modules
/node_modules
/npm-debug.log
View
3  package.json
@@ -18,7 +18,8 @@
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-watch": "~0.2.0",
"grunt-contrib-jasmine": "~0.3.0",
- "grunt-template-jasmine-requirejs": "~0.1.0"
+ "grunt-template-jasmine-requirejs": "~0.1.0",
+ "q": "~0.9.0"
},
"scripts": {
"postinstall": "grunt install",
View
3  src/config.json
@@ -33,7 +33,8 @@
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-watch": "~0.2.0",
"grunt-contrib-jasmine": "~0.3.0",
- "grunt-template-jasmine-requirejs": "~0.1.0"
+ "grunt-template-jasmine-requirejs": "~0.1.0",
+ "q": "~0.9.0"
},
"scripts": {
"postinstall": "grunt install",
View
63 tasks/build.js
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+/*global module, require*/
+
+module.exports = function (grunt) {
+ "use strict";
+
+ var child_process = require("child_process"),
+ q = require("q"),
+ qexec = q.denodeify(child_process.exec);
+
+ // task: build-num
+ grunt.registerTask("build-prop", "Write build.prop properties file for Jenkins", function () {
+ var done = this.async(),
+ out = "",
+ num,
+ branch,
+ sha,
+ opts = { cwd: process.cwd(), maxBuffer: 1024*1024 };
+
+ qexec("git log --format=%h", opts).then(function (stdout, stderr) {
+ num = stdout.toString().trim().split("\n").length;
+ return qexec("git status", opts);
+ }).then(function (stdout, stderr) {
+ branch = /On branch (.*)/.exec(stdout.toString().trim())[1];
+ return qexec("git log -1", opts);
+ }).then(function (stdout, stderr) {
+ sha = /commit (.*)/.exec(stdout.toString().trim())[1];
+
+ out += "build.number=" + num + "\n";
+ out += "build.branch=" + branch + "\n";
+ out += "build.sha=" + sha + "\n";
+
+ grunt.log.write(out);
+ grunt.file.write("build.prop", out);
+
+ done();
+ }, function (err) {
+ grunt.log.writeln(err);
+ done(false);
+ });
+ });
+};
Please sign in to comment.
Something went wrong with that request. Please try again.