Jenkins pipeline executing msbuild.exe (2019) build.xml - The batch file cannot be found - msbuild

pipeline {
agent { label 'Apps' }'''
environment {
MSBUILD_4_PATH = "c:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild"
MSBUILD_2019_PATH = "c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe"
GLOBAL_SETTINGS = "\\PATH\\TO\\msbuild_settings"
BUILD_TYPE = "Dev"
// ------
}
stage('Build Infra - Release and Test') {
steps {
dir("${env.WORKSPACE}/${BRANCH_NAME}/Infra/Build"){
bat '''
set DevEnvDir="c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\"
"%MSBUILD_2019_PATH%" Build.xml /p:GlobalSettings=%GLOBAL_SETTINGS%;BUILD_TYPE=%BUILD_TYPE%;SC=GIT;MSBuildCommunityTasksPath="C:\\Program Files (x86)\\MSBuild\\MSBuildCommunityTasks";ExtensionTasksPath="C:\\\\Program Files (x86)\\\\MSBuild\\\\ExtensionPack\\\\4.0\\\\" /t:ReleaseAndTest
'''
}
}
}
Please help, cant find root cause of the problem
Log finished with:
375 Warning(s)
0 Error(s)
Time Elapsed 00:04:54.35
The batch file cannot be found.
Cant realize if the problem is with Jenkins pipeline or MsBuild itself
stage never finished... stack
Tried many different options and still stack

Related

error building app with hermes: '..' is not recognized as an internal or external command

Building the react-native app on Windows 10.
The error is printed for line 165 of node_modules\react-native\react.gradle:
'..' is not recognized as an internal or external command, operable program or batch file
Line 165 is the 5th line in the following, starting with exec:
if (enableHermes) {
doLast {
def hermesFlags;
def hbcTempFile = file("${jsBundleFile}.hbc")
exec {
if (targetName.toLowerCase().contains("release")) {
// Can't use ?: since that will also substitute valid empty lists
hermesFlags = config.hermesFlagsRelease
if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"]
} else {
hermesFlags = config.hermesFlagsDebug
if (hermesFlags == null) hermesFlags = []
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags)
} else {
commandLine(getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags)
}
}
ant.move(
file: hbcTempFile,
toFile: jsBundleFile
);
if (hermesFlags.contains("-output-source-map")) {
ant.move(
// Hermes will generate a source map with this exact name
file: "${jsBundleFile}.hbc.map",
tofile: jsCompilerSourceMapFile
);
exec {
// TODO: set task dependencies for caching
// Set up the call to the compose-source-maps script
workingDir(reactRoot)
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", *nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile)
} else {
commandLine(*nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile)
}
}
}
}
}
Here is the definition of hermescommand in android/app/build.gradle:
project.ext.react = [
enableHermes: true, // clean and rebuild if changing
// next added by Yossi
hermesCommand: "../../node_modules/hermesengine/win64-bin/hermes",
extraPackagerArgs: ["--sourcemap-output", "$buildDir/intermediates/assets/release/index.android.bundle.map"]
]
Which, as far as I understand, points to the following file:
node_modules\hermes-engine\win64-bin\hermes.exe
Any idea?
Updated definition in android/app/build.gradle (following the answer below):
project.ext.react = [
enableHermes: true, // clean and rebuild if changing
// -either- hermesCommand: "..\\..\\node_modules\\hermesengine\\win64-bin\\hermes",
// -or- hermesCommand: "../../node_modules/hermesengine/%OS-BIN%/hermes",
hermesCommand: "../../node_modules/hermesengine/%OS-BIN%/hermes",
extraPackagerArgs: ["--sourcemap-output", "$buildDir/intermediates/assets/release/index.android.bundle.map"]
]
The build output now, after the change, is the following:
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Welcome to React Native!
Learn once, write anywhere
info Writing bundle output to:, C:\esites-grocery\test1\plumpclient\android\app\build\generated\assets\react\release\index.android.bundle
info Writing sourcemap output to:, C:\esites-grocery\test1\plumpclient\android\app\build/intermediates/assets/release/index.android.bundle.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 141 asset files
info Done copying assets
The system cannot find the path specified.
> Task :app:bundleReleaseJsAndAssets FAILED
> Task :app:bundleReleaseJsAndAssets_SentryUpload_3001
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.plumpplum#RN62 Hermes+3001 distribution 3001
> Bundled 2 files for upload
> Uploaded release files to Sentry
> File upload complete
Source Map Upload Report
Minified Scripts
~/index.android.bundle (sourcemap at index.android.bundle.map)
Source Maps
~/index.android.bundle.map
> Task :app:bundleReleaseJsAndAssets_SentryUpload_1001
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.plumpplum#RN62 Hermes+1001 distribution 1001
> Bundled 2 files for upload
> Uploaded release files to Sentry
> File upload complete
Source Map Upload Report
Minified Scripts
~/index.android.bundle (sourcemap at index.android.bundle.map)
Source Maps
~/index.android.bundle.map
> Task :app:bundleReleaseJsAndAssets_SentryUpload_2001
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.plumpplum#RN62 Hermes+2001 distribution 2001
> Bundled 2 files for upload
> Uploaded release files to Sentry
> File upload complete
Source Map Upload Report
Minified Scripts
~/index.android.bundle (sourcemap at index.android.bundle.map)
Source Maps
~/index.android.bundle.map
> Task :app:bundleReleaseJsAndAssets_SentryUpload_4001
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.plumpplum#RN62 Hermes+4001 distribution 4001
> Bundled 2 files for upload
> Uploaded release files to Sentry
> File upload complete
Source Map Upload Report
Minified Scripts
~/index.android.bundle (sourcemap at index.android.bundle.map)
Source Maps
~/index.android.bundle.map
FAILURE: Build failed with an exception.
* Where:
Script 'C:\esites-grocery\test1\plumpclient\node_modules\react-native\react.gradle' line: 165
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'cmd'' finished with non-zero exit value 1
Here's more of react.gradle:
def getHermesCommand = {
// If the project specifies a Hermes command, don't second guess it.
if (!hermesCommand.contains("%OS-BIN%")) {
return hermesCommand
}
// Execution on Windows fails with / as separator
return hermesCommand
.replaceAll("%OS-BIN%", getHermesOSBin())
.replace('/' as char, File.separatorChar);
}
You are specifying ../../node_modules/hermesengine/win64-bin/hermes as the path, which is OS specific (as determined by not having an OS placeholder).
As per the comment, react.gradle therefore doesn't second guess your path and just passes it directly to the OS command interpreter.
This fails because your command interpreter does not allow / as directory separator.
Either specify a path that's valid for your system:
hermesCommand: "..\\..\\node_modules\\hermesengine\\win64-bin\\hermes",
Or specify an OS-independent path to let react.gradle transform it for each platform:
hermesCommand: "../../node_modules/hermesengine/%OS-BIN%/hermes",

How to run Karate and Gatling with Gradle build system

I'm trying to run a Karate test as a Gatling performance test. My entire setup works perfect when using Maven. I am being forced to use Gradle however. When trying to run under Gradle the below disaster unfolds.
Appreciate any ideas what might be causing KarateAction to crash.
MyAPI.scala
class MyAPI extends Simulation {
val protocol = karateProtocol(
"/myendpoint" -> Nil
)
val action = karateFeature("classpath:org/mycompany/karate/tests/myAPI.feature#test=myTag")
setUp(
scenario("my-api")
.exec(action)
.inject(rampUsersPerSec(1) to (5) during (5 seconds))
.protocols(protocol)
)
}
build.gradle
buildscript {
ext {
karateVersion = '0.9.2'
}
}
apply plugin: 'scala'
configurations {
gatling
}
dependencies {
testCompile("com.intuit.karate:karate-apache:${karateVersion}")
testCompile("com.intuit.karate:karate-mock-servlet:${karateVersion}")
testCompile("com.intuit.karate:karate-junit4:${karateVersion}")
testCompile("com.intuit.karate:karate-gatling:${karateVersion}")
testCompile("net.masterthought:cucumber-reporting:3.8.0")
gatling "org.scala-lang:scala-library:2.12.8"
gatling "io.gatling:gatling-app:3.0.2"
gatling "io.gatling.highcharts:gatling-charts-highcharts:3.0.2"
gatling "com.intuit.karate:karate-gatling:${karateVersion}"
}
sourceSets {
simulations {
scala {
srcDirs = ['src/test/java/org/mycompany/karate/perf']
}
resources {
srcDirs = ['src/test/java/org/mycompany/karate/perf']
}
compileClasspath += configurations.gatling
}
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
}
}
}
test {
systemProperty "karate.options", System.properties.getProperty("karate.options")
systemProperty "karate.env", System.properties.getProperty("karate.env")
outputs.upToDateWhen { false }
}
task gatlingRun(type: JavaExec) {
description = 'Run Gatling Tests'
new File("${buildDir}/reports/gatling").mkdirs()
classpath = sourceSets.simulations.runtimeClasspath += configurations.gatling
main = "io.gatling.app.Gatling"
args = [
'-s', 'org.mycompany.karate.perf.MyAPI',
'-sf', 'src/test/java/org/mycompany/karate/perf',
'-rf', "${buildDir}/reports/gatling"
]
systemProperties System.properties
}
command line
gradle gatlingRun
command line output
> Task :compileSimulationsJava NO-SOURCE
> Task :compileSimulationsScala
Pruning sources from previous analysis, due to incompatible CompileSetup.
there were 6 feature warnings; re-run with -feature for details
one warning found
> Task :processSimulationsResources NO-SOURCE
> Task :simulationsClasses
> Task :gatlingRun
16:40:27.238 [main] INFO io.gatling.core.config.GatlingConfiguration$ - Gatling will try to use 'gatling.conf' as custom config file.
16:40:27.598 [GatlingSystem-akka.actor.default-dispatcher-3] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
16:40:28.242 [GatlingSystem-akka.actor.default-dispatcher-3] INFO io.gatling.core.stats.writer.ConsoleDataWriter - Initializing
16:40:28.242 [GatlingSystem-akka.actor.default-dispatcher-4] INFO io.gatling.core.stats.writer.LogFileDataWriter - Initializing
16:40:28.248 [GatlingSystem-akka.actor.default-dispatcher-3] INFO io.gatling.core.stats.writer.ConsoleDataWriter - Initialized
16:40:28.253 [GatlingSystem-akka.actor.default-dispatcher-4] INFO io.gatling.core.stats.writer.LogFileDataWriter - Initialized
Simulation org.mycompany.karate.perf.MyAPI started...
16:40:28.359 [GatlingSystem-akka.actor.default-dispatcher-2] ERROR com.intuit.karate.gatling.KarateAction - 'classpath:org/mycompany/karate/tests/myAPI.feature#test=myTag' crashed on session Session(my-api,1,1558395628341,Map(),0,OK,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$329/1759250827#7cee98de), forwarding to the next one
java.lang.NullPointerException: null
at com.intuit.karate.Resource.<init>(Resource.java:55)
at com.intuit.karate.core.FeatureParser.parse(FeatureParser.java:75)
at com.intuit.karate.FileUtils.parseFeatureAndCallTag(FileUtils.java:155)
at com.intuit.karate.Runner.callAsync(Runner.java:183)
at com.intuit.karate.gatling.KarateAction.execute(KarateAction.scala:77)
at io.gatling.core.action.Action.$bang(Action.scala:38)
at io.gatling.core.action.Action.$bang$(Action.scala:38)
at com.intuit.karate.gatling.KarateAction.io$gatling$core$action$ChainableAction$$super$$bang(KarateAction.scala:37)
at io.gatling.core.action.ChainableAction.$bang(Action.scala:63)
at io.gatling.core.action.ChainableAction.$bang$(Action.scala:61)
at com.intuit.karate.gatling.KarateAction.io$gatling$core$action$ExitableAction$$super$$bang(KarateAction.scala:37)
at io.gatling.core.action.ExitableAction.$bang(BlockExit.scala:138)
at io.gatling.core.action.ExitableAction.$bang$(BlockExit.scala:136)
at com.intuit.karate.gatling.KarateAction.$bang(KarateAction.scala:37)
at io.gatling.core.controller.inject.Workload.startUser(Workload.scala:55)
at io.gatling.core.controller.inject.Workload.injectUser(Workload.scala:64)
at io.gatling.core.controller.inject.open.OpenWorkload.$anonfun$injectBatch$1(OpenWorkload.scala:35)
at io.gatling.core.controller.inject.open.OpenWorkload.$anonfun$injectBatch$1$adapted(OpenWorkload.scala:35)
at io.gatling.core.controller.inject.open.UserStream.withStream(UserStream.scala:58)
at io.gatling.core.controller.inject.open.OpenWorkload.injectBatch(OpenWorkload.scala:35)
at io.gatling.core.controller.inject.Injector.$anonfun$inject$1(Injector.scala:60)
at io.gatling.core.controller.inject.Injector.$anonfun$inject$1$adapted(Injector.scala:59)
at scala.collection.Iterator.foreach(Iterator.scala:941)
at scala.collection.Iterator.foreach$(Iterator.scala:941)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)
at scala.collection.MapLike$DefaultValuesIterable.foreach(MapLike.scala:213)
at io.gatling.core.controller.inject.Injector.io$gatling$core$controller$inject$Injector$$inject(Injector.scala:59)
at io.gatling.core.controller.inject.Injector$$anonfun$1.applyOrElse(Injector.scala:92)
at io.gatling.core.controller.inject.Injector$$anonfun$1.applyOrElse(Injector.scala:82)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:38)
at akka.actor.FSM.processEvent(FSM.scala:684)
at akka.actor.FSM.processEvent$(FSM.scala:681)
at io.gatling.core.controller.inject.InjectorFSM.processEvent(InjectorFSM.scala:37)
at akka.actor.FSM.akka$actor$FSM$$processMsg(FSM.scala:678)
at akka.actor.FSM$$anonfun$receive$1.applyOrElse(FSM.scala:672)
at akka.actor.Actor.aroundReceive(Actor.scala:517)
at akka.actor.Actor.aroundReceive$(Actor.scala:515)
at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:24)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:588)
at akka.actor.ActorCell.invoke(ActorCell.scala:557)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258)
at akka.dispatch.Mailbox.run(Mailbox.scala:225)
at akka.dispatch.Mailbox.exec(Mailbox.scala:235)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
16:40:28.359 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG io.gatling.core.action.Exit - End user #1
16:40:28.360 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG io.gatling.core.controller.inject.open.OpenWorkload - Start user #1
16:40:28.363 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG io.gatling.core.controller.inject.open.OpenWorkload - Injecting 4 users in scenario my-api, continue=true
16:40:28.364 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG io.gatling.core.controller.inject.Injector - End user #1
16:40:29.347 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG io.gatling.core.controller.inject.open.OpenWorkload - Injecting 0 users in scenario my-api, continue=true
16:40:29.373 [GatlingSystem-akka.actor.default-dispatcher-2] ERROR com.intuit.karate.gatling.KarateAction - 'classpath:org/mycompany/karate/tests/myAPI.feature#test=myTag' crashed on session Session(my-api,2,1558395629372,Map(),0,OK,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$329/1759250827#7cee98de), forwarding to the next one
I have a gradle project with scala and java, and had to create a gradle task to move resources to the right folder, in order to make them available.
task copyResources(type: Copy) {
from ("src/test/java/") {
include "/**/*.feature"
include "karate-config*.js"
include "logback*.xml"
include "/**/*.csv"
include "/**/*.json"
}
into "$buildDir/classes/java/test/"
}
This is just a guess.
Your build.gradle defines src/test/java as resource folder:
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
}
}
The karate gatling demo defines src/test/scala as resource folder.
This is necessary, because otherwise the *.feature files next to your scala/java source files are not treated as part of the resulting artifact.
Furthermore, you are using the classpath of the simulation source set when running gatling test. Make sure, that your *.feature are included in that classpath.
As an alternative, you can put your *.feature files under src/test/resources/com/your/package, but this increases "the distance" between your feature and source code files.
Debugging Hint:
Print the file tree of your build/resources folder in order to check whether or not the feature files are included in the resulting build artifact and that the path matches the path you are referencing in your runner.
Let me know if this was useful!

gulp task runner msbuild fails, but works in cmd

I have a project where Gulp task runner is setup. Everything works perfectly fine in VS2015, but when I upgraded to VS2017 MSBuild started to fail.
The funny thing is, that if I copy out the command line that apparently fails and paste it into the cmd, then it works perfectly fine.
I get the following error:
[09:47:27] Building project: ..\DFS.Client\DFS.Client.csproj
[09:47:27] Using automatic maxcpucount
[09:47:27] Building project: 1 item
[09:47:27] { Error: Command failed: "C:\Program Files
(x86)\MSBuild\14.0\Bin\MSBuild.exe"
"C:\solutions\dfs\code\DFS.Client\DFS.Client.csproj" "/target:Clean;Build"
/verbosity:minimal /toolsversion:14.0 /nologo /maxcpucount
/property:Configuration="Debug" /property:DeployOnBuild="true"
/property:DeployDefaultTarget="WebPublish"
/property:WebPublishMethod="FileSystem"
/property:DeleteExistingFiles="false"
/property:publishUrl="C:\inetpub\wwwroot\dfsdev\Website"
/property:_FindDependencies="true"
at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
killed: false,
code: 1,
signal: null,
cmd: '"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe"
"C:\\solutions\\dfs\\code\\DFS.Client\\DFS.Client.csproj"
"/target:Clean;Build" /verbosity:minimal /toolsversion:14.0 /nologo
/maxcpucount /property:Configuration="Debug" /property:DeployOnBuild="true"
/property:DeployDefaultTarget="WebPublish"
/property:WebPublishMethod="FileSystem"
/property:DeleteExistingFiles="false"
/property:publishUrl="C:\\inetpub\\wwwroot\\dfsdev\\Website"
/property:_FindDependencies="true"' }
[09:47:27] Build failed!
If I copy the command line that is stated as failing and run it in CMD it works. I have tried the following fix without any luck.
The gulp task that fails looks like this:
var publishProjects = function (location, dest) {
dest = dest || config.websiteRoot;
var targets = ["Build"];
if (config.runCleanBuilds) {
targets = ["Clean", "Build"];
}
console.log("publish to " + dest + " folder");
return gulp.src([location + "/**/*.csproj"])
.pipe(foreach(function (stream, file) {
return stream
.pipe(debug({ title: "Building project:" }))
.pipe(msbuild({
targets: targets,
configuration: config.buildConfiguration,
logCommand: false,
verbosity: "minimal",
maxcpucount: 0,
toolsVersion: 14.0,
properties: {
DeployOnBuild: "true",
DeployDefaultTarget: "WebPublish",
WebPublishMethod: "FileSystem",
DeleteExistingFiles: "false",
publishUrl: dest,
_FindDependencies: "true"
}
}));
}));
};
Help would be appreciated as I would really like to use VS2017 rather than 2015.
Tools version 14.0 is for VS2015, tools version 15.0 is for VS2017. There is some other config you may need to change to enable it as well. Hope that helps.

Error publishing ASP.NET Core project

I have an ASP.NET Core RC1 project that no longer publishes correctly (see publish trace output, below). The gulp min task in the prepublish script defined in project.json is causing the error. If I remove it, the project publishes correctly, but without minifying the js and css files.
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
I have added another Web Project to the solution, and that publishes without error, so I think that eliminates environmental issues. However, I can't see anything substantially different between the test project and the one that fails.
I have also deleted the node_modules folder in the failing project to force Visual Studio to download all the npm packages again.
Finally I ran the dnu publish command in the trace below from the VS command prompt and that also failed.
Can anyone tell me what the problem is from the error trace below, please?
Connecting to C:\svn\Client Applications\yyy\xxx\src\xxxWeb\..\..\artifacts\bin\xxx.Web\Release\PublishOutput...
Environment variables:
Path=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\ptayl_000\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-final\bin\dnu.cmd publish "C:\svn\Client Applications\yyy\xxx\src\xxxWeb" --out "C:\Users\ptayl_000\AppData\Local\Temp\PublishTemp\xxx.Web104" --configuration Release --no-source --runtime dnx-clr-win-x86.1.0.0-rc1-final --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web" --quiet
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16202
Executing script 'prepublish' in project.json
v0.10.31
npm WARN package.json ASP.NET#0.0.0 No description
npm WARN package.json ASP.NET#0.0.0 No repository field.
npm WARN package.json ASP.NET#0.0.0 No README data
[07:36:31] Using gulpfile C:\svn\Client Applications\yyy\xxx\src\xxxWeb\gulpfile.js
[07:36:31] Starting 'clean:js'...
[07:36:31] Starting 'clean:css'...
[07:36:31] Finished 'clean:js' after 1.68 ms
[07:36:31] Finished 'clean:css' after 1.99 ms
[07:36:31] Starting 'clean'...
[07:36:31] Finished 'clean' after 9.03 μs
[07:36:32] Using gulpfile C:\svn\Client Applications\yyy\xxx\src\xxxWeb\gulpfile.js
[07:36:32] Starting 'min:js'...
[07:36:32] Starting 'min:css'...
[07:36:32] Finished 'min:css' after 61 ms
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : events.js:72
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : throw er; // Unhandled 'error' event
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : ^
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : Error
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at new JS_Parse_Error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:196:18)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at js_error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:204:11)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at croak (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:675:9)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at token_error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:683:9)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at expect_token (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:696:9)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at expect (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:699:36)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1252:13
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:722:24
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at expr_atom (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1182:35)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at maybe_unary (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1358:19)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : The 'prepublish' script failed with status code 8.
2>Publish failed due to build errors. Check the error list for more details.
Update
The gulp min task contains the following code (from gulp.js):
gulp.task("min:js", function () {
return gulp.src([paths.js, "!" + paths.minJs], { base: "." })
.pipe(concat(paths.concatJsDest))
.pipe(uglify())
.pipe(gulp.dest("."));
});
Update2: event.js
var rx = require("rx");
function normalizeKeypressEvents(args) {
return { value: args[0], key: args[1] };
}
module.exports = function(rl) {
return {
line: rx.Observable.fromEvent(rl, "line"),
keypress: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents),
normalizedUpKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.key && (e.key.name === "up" || e.key.name === "k");
}).share(),
normalizedDownKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.key && (e.key.name === "down" || e.key.name === "j");
}).share(),
numberKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.value && "123456789".indexOf(e.value) >= 0;
}).map(function(e) {
return Number(e.value);
}).share(),
spaceKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.key && e.key.name === "space";
}).share(),
};
};
Turned out that it was a piece of application javascript that was causing the "gulp min" task to fail. The culprit was the following seemingly innocuous piece of code:
$http.get(uri, { params: { config } }).then(function (data) {
return data;
});
I still can't see any problem with it, but as the code had become redundant, I removed it and solved the problem that way.
I was getting the same issues (even on the same line numbers). Paul's own answer gave me a clue to look carefully at my own .js
I commented out most of the file and then progressively uncommented blocks of code until the errors came back.
And the offending code?
This line that uses a template string was the problem:
rtUl.insertAdjacentHTML("beforeend", `<li>${el.toString()}</li>`);
Changing it back to a simple concatenation worked:
rtUl.insertAdjacentHTML("beforeend", "<li>" + el.toString() + "</li>");
It seems that uglify can't read string templates (yet).

Setting up Continuous Integration of Protractor using Jenkins

I am writing automation test scripts using Protractor and now I need to set up the CI for this using Jenkins.
Tasks it needs to perform are:
Starting the selenium standalon server.
Starting the test using conf.js file.
Stopping the selenium standalone server.
Can anyone help in this regard?
I created a small bash script to do this.
# start selenium
./node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 &
# wait until selenium is up
while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done
# run the build
grunt cibuild --force
# stop selenium
curl -s -L http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer > /dev/null 2>&1
This script is invoked from a free-style project in jenkins (Build > Execute shell)
Then the test result report is generated by reading the protractor test results. Hence, you have to produce junit reports from protractor, (look here) :
onPrepare: function() {
// The require statement must be down here, since jasmine-reporters
// needs jasmine to be in the global and protractor does not guarantee
// this until inside the onPrepare function.
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('xmloutput', true, true));
},
To make the report visible in jenkins i add a post build action in the job: Publish JUnit test result report:
Alternatively, you could run this as a Grunt Task. First install grunt on Jenkins. Install the NPM packages for protractor_webdriver and protractor. Setup the configuration file to point the the node_module path and config file paths.
http://sideroad.secret.jp/articles/grunt-on-jenkins/
Then install protractor node modules. The Gruntfile would look similar to this. I created a test directory where the conf and spec files would be located.
module.exports = function (grunt) {
grunt.initConfig({
protractor_webdriver: {
your_target: {
options: {
path: 'node_modules/protractor/bin/',
command: 'webdriver-manager start'
}
}
},
protractor: {
options: {
configFile: "node_modules/protractor/referenceConf.js", // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
args: {
// Arguments passed to the command
}
},
your_target: {
options: {
configFile: "test/conf.js", // Target-specific config file
args: {} // Target-specific arguments
}
}
}
});
grunt.registerTask('p:test', [
'protractor_webdriver',
'protractor'
]);
});
The newest protractor allows you to run the selenium standalone server directly from the conf.js (or whatever protractor entry point you have).
comment out (or delete) the seleniumAddress: 'http://localhost:4444/wd/hub', line, and replace it with seleniumServerJar: './node_modules/protractor/selenium/latest.jar'.
latest.jar isn't installed by default, I created it as a symlink to the latest version installed via npm install protractor --save. This gives longer life to my conf.js files in the same directory.
Within the ./node_modules/protractor/selenium/ folder I ran ln -s selenium-server-standalone-2.48.2.jar latest.jar
You can use Gulp which is far simpler.
After installing gulp in Jenkins System , you may install the npm dependencies(npm install) & run gulp tasks directly as windows batch command in Jenkins as below:
In the background to make selenium server up and running and providing various other parameters , you may use packages like 'gulp-angular-protractor' in the gulpfile.js as below:
gulpfile.js
'use strict';
var gulp = require('gulp'),
gulpProtractorAngular = require('gulp-angular-protractor'),
gulpStart = gulp.Gulp.prototype.start,
currentStartTaskName;
gulp.Gulp.prototype.start = function (task) {
currentStartTaskName = task;
gulpStart.apply(this, arguments);
};
function executeWebTests(suiteName, appName) {
return gulp.src([])
.pipe(gulpProtractorAngular({
'configFile': './conf.js',
'debug': false,
'autoStartStopServer': true,
args: [
'--suite', suiteName,
'--capabilities.browserName', 'chrome',
'--params.APPNAME', appName,
'--params.SUITENAME', currentStartTaskName,
'--capabilities.platformName', 'Windows'],
keepAlive: false
}))
.on('error', function (e) {
console.log('Ended with below ERROR::',e);
process.exit(1);
})
.on('end', function () {
console.log('Test complete');
process.exit();
});
}
gulp.task('RegressionSuiteTask', function () {
executeWebTests('regressionTests,','Application_Name');
});
conf.js
suites: {
regressionTests: ['testCases/**/*.js']//will run all specs in subfolders
},
I know this already resolved and want to target for beginner to create Jenkins job and running test. I suggest to use selenium-server-standalone jar in configuration file and call configuration file from Jenkins.
conf.js
..
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumServerJar: 'node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.5.3.jar',
....
//html reporter logic
.....
Creating Jenkins Job
Install node js on Jenkins Server
Install Html Publisher Plugin for end to end testing report
Create Freestyle Project or whatever your needs
Go to Build Section -> Add build step and choose Execute Windows
batch command if Jenkins server in Windows otherwise choose Execute
Shell for Linux
Call conf.js (install packages and call your configuration file)
For reporting Got to Post-Build Actions Section -> Add Publish Html
Reports and call your report file (file assuming from root of your
project)
However you can customize execution command using gulp or similar other packages. Thanks