0

I'm pretty new to teamcity and I'm having some difficulties understanding how to pass values to my gulp-config.js, which is used to setup the config to build and deploy a sitecore helix project with gulp msbuild.

I've created a new standard paramater in teamcity, called BuildConfiguration and in my guilpconfig I used it like :

var config = {
    Configuration = %BuildConfiguration%,
    ...
}

Teamcity doesn't seem to be able to replace the variables inside the gulp file. What am I doing wrong?

Thanks a lot :)

Chris Watts
  • 822
  • 1
  • 9
  • 27
A. C.
  • 45
  • 7
  • You need to pass them as arguments to the config if possible. Teamcity wont format the file but will format the command that calls it. Have a look at your gulp step, cant remember off the top of my head, but you need to pass `%BuildConfiguration%` as a param/arg to the gulpfile – Chris Watts Jun 15 '18 at 19:23
  • In fact, see here, then you just need to implement the relevant args in your script https://stackoverflow.com/questions/28538918/pass-parameter-to-gulp-task – Chris Watts Jun 15 '18 at 19:24
  • I passed them in on the command line in the "Additional Command Line Parameters box", and used `gulp-yargs` to pull them off the command line and into the script. –  Jun 15 '18 at 20:19
  • Hi Chris, I have actually thought about this solution but I assumed it was only a workaround. Thank you very much! – A. C. Jun 15 '18 at 20:25
  • @A.C. it's not a workaround. TeamCity isn't going to perform substitutions in arbitrary files. That's a powershell thing, and the gulpfile isn't a Powershell script. Besides, doing it that way would make it harder to use on your local machine. –  Jun 15 '18 at 20:26

1 Answers1

0

Thanks a lot Amy and Chris.

I've used:

var parsedArgs = require("minimist")(process.argv.slice(2));

and in my gulpfile:

...
   .pipe(msbuild({
       targets: targets,
       configuration: parsedArgs.buildConfiguration,
       ...

and in teamcity, in the advanced area of the gulp task:

--buildConfiguration %buildConfiguration% --otherArg %value%
A. C.
  • 45
  • 7