Base solution for your next web application
Open Closed

TeamCity NPM Create Bundles #12338


User avatar
0
GeovaniMartinez created

Our TeamCity CI/CD breaks when we execute npm run create-bundles ; the command does what it needs to do but it's not returning an exit code of 0

Step 3/9: NPM Create Bundles (Node.js NPM)
13:17:08   npm run create-bundles
13:17:14     
13:17:14     > abpzerotemplate@13.1.0 create-bundles
13:17:14     > yarn && gulp buildDev
13:17:14     
13:17:16     yarn install v1.22.21
13:17:16     [1/4] Resolving packages...
13:17:17     success Already up-to-date.
13:17:17     Done in 1.09s.
13:17:25     [14:17:25] Using gulpfile C:\TeamCity\buildAgent\work\b17c74ca8e23fd01\src\solution.Web.Mvc\gulpfile.js
13:17:25     [14:17:25] Starting 'buildDev'...
13:17:30     Bundles are being created, please wait...
13:17:42     C:/TeamCity/buildAgent/work/b17c74ca8e23fd01/src/solution.Web.Mvc/wwwroot/view-resources/Areas/D10/Views/Outbound/Index.min.js updated
13:17:42     C:/TeamCity/buildAgent/work/b17c74ca8e23fd01/src/solution.Web.Mvc/wwwroot/view-resources/Areas/D10/Views/Incoming/Index.min.js updated
13:17:42     C:/TeamCity/buildAgent/work/b17c74ca8e23fd01/src/solution.Web.Mvc/wwwroot/view-resources/Areas/D10/Views/Outbound/Index.min.js updated
13:17:42     C:/TeamCity/buildAgent/work/b17c74ca8e23fd01/src/solution.Web.Mvc/wwwroot/view-resources/Areas/D10/Views/Incoming/Index.min.js updated
13:17:43     C:/TeamCity/buildAgent/work/b17c74ca8e23fd01/src/solution.Web.Mvc/wwwroot/view-resources/Areas/D10/Views/Incoming/Index.min.js updated
13:17:43     C:/TeamCity/buildAgent/work/b17c74ca8e23fd01/src/solution.Web.Mvc/wwwroot/view-resources/Areas/D10/Views/Outbound/Index.min.js updated
13:17:47     [14:17:47] Finished 'buildDev' after 22 s
13:17:08   Executing npm via wrapping shell script
13:17:08   Starting: cmd /c npm run create-bundles
13:17:08   in directory: C:\TeamCity\buildAgent\work\b17c74ca8e23fd01\src\solution.Web.Mvc
13:31:53   The build fake domain::http://dev.demo.fakedomain.com (Development) [#162](https://support.aspnetzero.com/QA/Questions/162) {buildId=13765} has been running for more than 15 minutes. Terminating...
13:31:58   Execution timeout
13:31:53   Stopping build on agent. Reason: build execution timeout
13:32:01   PID: 996, PPID: 11496, Command line: cmd /c npm run create-bundles
13:32:01   Error -68. Failed to get thread dump from non-java process.
13:32:01   
13:32:01   PID: 9872, PPID: 996, Command line: "C:\Program Files\nodejs\\node.exe"  "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" run create-bundles
13:32:01   Error -68. Failed to get thread dump from non-java process.
13:32:01   
13:32:01   PID: 6572, PPID: 9872, Command line: C:\Windows\system32\cmd.exe /d /s /c yarn && gulp buildDev
13:32:01   Error -68. Failed to get thread dump from non-java process.
13:32:01   
13:32:01   PID: 4692, PPID: 6572, Command line: node   "C:\TeamCity\buildAgent\work\b17c74ca8e23fd01\src\solution.Web.Mvc\node_modules\.bin\\..\gulp-cli\bin\gulp.js" buildDev
13:32:01   Error -68. Failed to get thread dump from non-java process.
13:32:01   
13:32:01   PID: 80, PPID: 996, Command line: \??\C:\Windows\system32\conhost.exe 0x4
13:32:01   Error -68. Failed to get thread dump from non-java process.
13:32:01   
13:32:02   Process exited with code 1

We tried updating the gulpfile.js in various ways but can't seem to get the desired output; below is our last attempt

function buildDev() {
  fillScriptBundles();
  fillStyleBundles();
  fillScriptMappings();

  var scriptTasks = createScriptBundles();
  var styleTasks = createStyleBundles();

  watchScriptEntries();
  watchStyleEntries();

  console.log('Bundles are being created, please wait...');

  var stream = merge(scriptTasks.concat(styleTasks));
    return !stream.isEmpty() ? stream : process.exitCode(0);
}

2 Answer(s)
  • User Avatar
    0
    GeovaniMartinez created

    (reverted gulpfile.js changes to original code base)

    The solution to this issue is to use the npm run buildcommand instead of npm run create-bundles on the TeamCity build step. The process will appear to hang at the Starting 'build'... step but its working in the background and completes after few minutes then returns the expected exit code.

    07:58:27 Step 3/9: NPM Run Build Command (Node.js NPM)
    07:58:27   npm run build
    07:58:32     
    07:58:32     > abpzerotemplate@13.1.0 build
    07:58:32     > yarn && gulp build
    07:58:32     
    07:58:34     yarn install v1.22.21
    07:58:34     [1/4] Resolving packages...
    07:58:34     success Already up-to-date.
    07:58:34     Done in 0.69s.
    07:58:46     [08:58:46] Using gulpfile C:\TeamCity\buildAgent\work\b17c74ca8e23fd01\src\solution.Web.Mvc\gulpfile.js
    07:58:46     [08:58:46] Starting 'build'...
    08:05:44     [09:05:44] Finished 'build' after 6.97 min
    07:58:27   Executing npm via wrapping shell script
    07:58:27   Starting: cmd /c npm run build
    07:58:27   in directory: C:\TeamCity\buildAgent\work\b17c74ca8e23fd01\src\solution.Web.Mvc
    08:05:44   Process exited with code 0```
    
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @GeovaniMartinez

    When running the commands to create bundles and minify files using Gulp, the npm run build command is executed for the production environment. On the other hand, the npm run create-bundles command is executed for the development environment. The main difference between these two commands is that in the development environment, Gulp uses watch to monitor changes, so the terminal does not terminate automatically. If you want to terminate the terminal in the development command, you can remove the watch functions (watchScriptEntries, watchStyleEntries) from the buildDev function. However, when removing the methods here, if there are changes in the relevant javascript and style files in the development environment, they will not be reflected in the bundle and minify files. You will need to run the command again for changes.