Jenkins build error "Execution failed for task ':buildAngular'"


(Hawa Djikine) #1

Hello,
Thanks in advance for your help. I am setting up a Jenkins job to build a war & deploy it in a remote tomcat server. At first, the build failed because it couldn’t process npm.cmd. I installed Node.js & NPM on the Jenkins server & made sure the angular dependencies are included in build.gradle . Now the build is failing with the below error.

09:18:11 :buildAngular FAILED
09:18:11
09:18:11 FAILURE: Build failed with an exception.
09:18:11
09:18:11 * What went wrong:
09:18:11 Execution failed for task ‘:buildAngular’.
09:18:11 > A problem occurred starting process 'command ‘ng.cmd’'
09:18:11
09:18:11 * Try:
09:18:11 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
09:18:11
09:18:11 BUILD FAILED

build.gradle:

dependencies {
compile(‘org.springframework.boot:spring-boot-starter-web’)
testCompile(‘org.springframework.boot:spring-boot-starter-test’)
}

def webappDir = “$projectDir/src/main/webapp"
sourceSets {
main {
resources {
srcDirs = [”$webappDir/dist", “$projectDir/src/main/resources”]
}
}
}

processResources {
dependsOn “buildAngular”
}

task buildAngular(type:Exec) {
	// installAngular should be run prior to this task
	dependsOn "installAngular"
	workingDir "stack-angular"
	inputs.dir "stack-angular"
	// Add task to the standard build group
	group = BasePlugin.BUILD_GROUP
	// ng doesn't exist as a file in windows -> ng.cmd
	if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")){
		commandLine "ng.cmd", "build"
	} else {
		commandLine "ng", "build"
	}
}

task installAngular(type:Exec) {
	workingDir "stack-angular"
	inputs.dir "stack-angular"
	group = BasePlugin.BUILD_GROUP
	if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")){
		commandLine "npm.cmd", "install"
	} else {
		commandLine "npm", "install"
	}
}