My current code uses the command line argument delimiter to set a property in a gulp file
gulp --AssemblyInfoVersion "1.2.3"
I pick up the set variable inside the gulp.js with
var version = gutil.env.AssemblyInfoVersion
Inside the Gulp build task, I tried to use the field Environment Variables to set AssemblyInfoVersion, but that does not seem to work.
AssemblyInfoVersion="1.0.${bamboo.buildnumber}"
How do I access the Environment Variables via the build task?, or how do I pass the variables?
Community moderators have prevented the ability to post new answers.
Hello Dann,
If you look at the build log generated, you can find the command Bamboo is executing. In the log entry below, you can notice the Environment Variables under Advanced options is not appended to the command executed:
command 28-Dec-2016 14:31:12 Beginning to execute external process for build 'Project - Plan - Default Job #8 (PROJ-PLAN-JOB1-8)'\n ... running command line: \n/usr/local/bin/node node_modules/gulp/bin/gulp.js scripts\n
Instead, you need to pass the arguments directly into the Task:
command 28-Dec-2016 14:32:45 Beginning to execute external process for build 'Project - Plan - Default Job #9 (PROJ-PLAN-JOB1-9)'\n ... running command line: \n/usr/local/bin/node node_modules/gulp/bin/gulp.js scripts --env production --buildNumber 9\n
// npm install gulp yargs gulp-if gulp-uglify gulp-minify-css gulp-rename var gulp = require('gulp'); var args = require('yargs').argv; var gulpif = require('gulp-if'); var uglify = require('gulp-uglify'); var minifyCss = require("gulp-minify-css"); var rename = require('gulp-rename'); var isProduction = args.env === 'production'; var buildNumber = (args.buildNumber === "undefined") ? 0 : args.buildNumber; // task gulp.task('scripts', function () { gulp.src('./css/sample.css') // path to your file .pipe(gulpif(isProduction, minifyCss({keepBreaks: true}))) .pipe(rename({ suffix: '.' + buildNumber + '.min' })) .pipe(gulp.dest('./css/minified')); });
body { background-color: white } div { width: auto; }
image2016-12-28 14:35:0.png
scripts --env production --buildNumber ${bamboo.buildNumber}
Please, notice the Bamboo variable must be ${bamboo.buildNumber} and not ${bamboo.buildnumber} as you mentioned.
As a result, you will have:
body{background-color:#fff} div{width:auto}
—
Kind regards,
Rafael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.