Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown command error in Jenkins when running Cake script using Powershell

Our Jenkins server has been successfully building projects for years using Powershell to run a cake script. Out of the blue today, we started getting the following error on multiple projects:

12:10:46 Running build script...
12:10:46 
12:10:46 Error: Unknown command 'Default'.
12:10:46 
12:10:46        .\scripts\build.cake -target=Default -configuration=Release 
12:10:46 -verbosity=Verbose -environment=dev -certificatePath=C:/Program Files 
12:10:46 (x86)/xxxxx/Verisign Certificate -certificateName=xxxxxxxx_cert.pfx 
12:10:46 -certificatePassword=xxxxxxxxxxx
12:10:46                                     ^^^^^^^ No such command
12:10:46 
12:10:47 Build step 'Windows PowerShell' marked build as failure

The build.ps1 script has not changed. The build.cake script has not changed. Jenkins was not updated since the last successful builds nor any of the add-ins.

If I remove "-target=Default" from the argument list, I just get the same error on "-configuration=Release" indicating unknown command: "Release".

Has anyone else experienced this?

like image 952
acordner Avatar asked Feb 09 '21 19:02

acordner


People also ask

Is the Jenkins instance/node the same server where I installed a module?

To answer your next question, I was really confident but now am questioning this. lol So, to start, yes, the Jenkins instance/node (server) is the same server where I installed this module and created the script that is running. But, when I run Get-Module in Shell I get a very small list of Modules and none of which are ones I installed.

Where is WSUS_cleanup folder in Jenkins?

ex. Job in Jenkins is called WSUS_Cleanup, so I added the PoshWSUS folder to the C:\Program Files (x86)\Jenkins\workspace\WSUS_Cleanup folder I then changed the Log on as option in the Jenkins service to my _adm domain account.

Can cakehost be used directly to create the cakehost object?

With Cake Frosting 1.0 CakeHost can be used directly to create the CakeHost object. With Cake Frosting 0.38.x: With Cake Frosting 1.0:

What is non-terminating error in PowerShell?

Hence, these types of errors are known as “non-terminating” errors. If you set $ErrorActionPreference to Stop or if you use Stop as the parameter value for -ErrorAction, Windows PowerShell will stop the script execution at the point an error occurs.


1 Answers

The possible root cause of this failure is the cake version update (0.38.x --> 1.0)

You have two ways to fix this issue

  1. Change the Argument Syntex - arguments should always be called with multi-dash syntax (e.g. --target=Foo) instead of (e.g. -target=Foo) Refer: https://cakebuild.net/docs/getting-started/upgrade

  2. Pinning the cake version

Specified the version of Cake in the tools/packages.config file Refer: https://cakebuild.net/docs/writing-builds/reproducible-builds/pinning-cake-version

like image 53
Nim Avatar answered Sep 28 '22 19:09

Nim