Exec Task - sequential tasks of type Exec exit abnormally


(Julian Hall) #1

I’ve recently upgraded to 2.13 and I’ve got a strange situation where I have two Exec tasks that run one after another (where one depends on another).

One Exec task will complete and then will just exit without any info (no exceptiton, no “build successful” or anything … just stops) before running the next.

If i attempt to run it with the debug/info/stack trace - but then it always completes successfully. (ughh)
(one side note : i’m no longer getting the output from the tasks printed to the console either).

My code is running on windows 10/7 and it attempting to install an IIS app and assign the application pool.
This simplified code has been running with 2.2.1 for years with no issues, but now with 2.13 no luck
I didn’t see any ‘breaking changes’ from the release notes.
Anyone have any ideas would be greatly appreciated.

tasks.create( name: "createWebApp_${tier.key}",
			type: Exec,
			dependsOn: ["createAppPool_${tier.key}"] //AppPool must exist!)  { task ->
			
				args("\\\\${tier.value.host}",
					appcmd_loc,
					"add",
					"app",
					"/site.name:Default Web Site",
					"/path:/${tier.value.context}",
					"/physicalPath:${tier.value.dir.replace('/','\\')}")
				executable "paexec.exe"
				ignoreExitValue = true
				doLast {
					assert execResult.exitValue in [0,183]//183 exists already.
				}
				onlyIf {//we add the onlyIf cluase here so that at execution time we are allowed to run it.
					fileExists(appcmd_loc, tier.value.host)
				}
		}
		
tasks.create( name: "assignAppPool_${tier.key}",
			type: Exec,
			dependsOn: ["createWebApp_${tier.key}"] //need to create the application pool!)  { task ->
		
				args("\\\\${tier.value.host}",
						appcmd_loc,
						"set",
						"app",
						"Default Web Site/${tier.value.context}",
						"/applicationPool:${env}_${cfgFilename}")
				executable "paexec.exe"
				ignoreExitValue = true
				doLast {
					assert execResult.exitValue in [0,1168]
				}
				onlyIf {//we add the onlyIf cluase here so that at execution time we are allowed to run it.
					fileExists(appcmd_loc, tier.value.host)
				}
		}

Thanks,

Julian