Jenkins parameter is getting replaced by a white space - batch-file

I have a parameterized build (copied from an existing job) in Jenkins. While building, my parameter is getting replaced by a white space. Here I am sharing what I have.
Parameter Name: BuildDate (I tried using %% and ${} but no luck)
Windows batch command:
copy \\Network_drive\dir1\dir2\dir3%BuildDate%\filename*.zip .
Output from Jenkins console:
c:\jenkins\workspace\my_build_job_name>copy \\Network_drive\dir1\dir2\dir3\ \filename*.zip .
\\Network_drive\dir1\dir2\dir3\ \filename*.zip
The system cannot find the path specified. 0 file(s) copied
c:\jenkins\workspace\my_build_job_name>exit 1
Build step 'Execute Windows batch command' marked build as failure
Notifying upstream projects of job completion Finished: FAILURE*
Note: We have a Windows/Linux mixed environment. Whenever we want to run shell scripts, we use Cygwin, batch should directly run.

Finally it turned out that one of the parameters was not populating due to hitting "rebuild last". Re-running the whole pipeline did it work. I still wonder why it was not populating but its all hood now!!!

Related

Execute a Workflow KNIME with a Batch file

I would like to execute a workflow KNIME with a Batch file but i have an error :
ERROR KNIME-Worker-2 Call Local Workflow Execute failed : java.lang.NullPointerException
My workflow knime work well on Knime but i don't know why I have this error.
This is my Batch file :
"C:\Program Files\KNIME\knime.exe" -nosave -consoleLog -noexit -nosplash -reset
-application org.knime.product.KNIME_BATCH_APPLICATION
-preferences="C:\Users\Admnistrator\Desktop\KNIME_Preferences.epf"
-workflowDir="C:\Users\Admnistrator\knime-workspace\SPC_SIMTest"
Knime report Java :
Java was started but returned exit code = 4
I'm not find solution. Can you help me ?
If you run the command without options, e.g. eclipsec.exe -consoleLog -noexit -nosplash -launcher.suppressErrors -application org.knime.product.KNIME_BATCH_APPLICATION
then you will see a list of the available options and the java return codes. In particular, return code 4 indicates if an error during execution occurred
Often this sort of problem can be fixed by openning the workflow in the KNIME desktop, checking for any errors, reset the workflow and save it again, as an error during loading (e.g partially executed loops to pick a common one) could cause problems. Then try re-loading the workflow in the KNIME desktop and check no errors during load are recorded during the console. Also, adding the option --launcher.suppressErrors to your command line can sometimes avoid issues like this.

TeamCity - start tomcat

I'm trying to start tomcat with a teamcity deployment build step. The steps below all work with no issues when ran directly, but do not work in a teamcity step. The java window appears and closes, as though the build step kills all child processes when completed. I have tried all of the following:
batch (command line running a batch in sources, or right in teamcity script, and command line, and process build types):
call "%env.CATALINA_HOME%\bin\startup.bat"
start "%env.CATALINA_HOME%\bin\startup.bat"
cmd /k "%env.CATALINA_HOME%\bin\startup.bat"
start "DEV server" "%env.CATALINA_HOME%\bin\startup.bat"
powershell:
# wasnt sure if env var was being carried over, not relevant
$env:CATALINA_HOME = %env.CATALINA_HOME%
Start-Process "%env.CATALINA_HOME%\bin\startup.bat"
is there some way to tell TeamCity 10 build step 'hey, leave whatever was started running'?
CATALINA_HOME is an environment variable in the teamcity parameters (env.CATALINA_HOME) and is set to "C:\apache-tomcat" which is correct.
Some additional information: the TC server and agent is running as a user account, the user account has access to all folders (and is local admin) as well.
in tomcat bin\setenv.bat I had CATALINA_OPTS -XmX and -Xms parameters which were very large and required 64 bit java.
When doing this specific build parameter (which I recommend for debugging, it will block the TC build)
%env.CATALINA_HOME%\bin\catalina.bat
(argument: run)
I then got an exit code 1 build failure with a useful error message (but no tomcat logs):
[08:25:24]Error: Could not create the Java Virtual Machine.
[08:25:24]Error: A fatal exception has occurred. Program will exit.
[08:25:24]Invalid maximum heap size: -Xmx32768m
[08:25:24]The specified size exceeds the maximum representable size.
[08:25:24]Process exited with code 1
If you need large Xmx and Xms of a child process, the BUILD AGENT executing the build needs to be running from 64 bit as well! In my case, I had, eg
C:\Teamcity_BuildAgent_Deploy\jre
I copy pasted my 64 bit jre installation in there as well per TC docs and then it could start processes with large Xmx and Xms. I did not adjust TEAMCITY_AGENT_MEM_OPTS or any batches.

manage Jenkins build status

I'd like to run batch using jenkins. And the status of build depends of number of files created in a specific folder. My question is how could I manage Jenkins build status depending of number of files created?
You can execute a shell script to count the files and return 1, if the count isn't expected.
Another way would be to use the Text-finder Plugin searching for a pattern in the console log.
Groovy Postbuild Plugin is another alternative:
buildUnstable() - sets the build result to UNSTABLE.
If you like to use the CLI you can use the following command:
java -jar jenkins-cli.jar -s http://...:8080/ set-build-result
Sets the result of the current build. Works only if invoked from within a build.

TortoiseSVN batch file output info

I am trying to do the equivalent of the following Linux command with a Windows batch file and TortoiseSVN.
svn info > info.txt
I have tried the following with no luck:
start /wait "" "c:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:info >> %CD%\info.txt
I am running Windows with TortoiseSVN v1.6.16 so I don't have access to the command line tools.
Note: We were encountering issues with the newer version of TortoiseSVN so we went back to 1.6 until issues are resolved with a newer version and the company upgrades the server to that version.
Your construction didn't work, doesn't work and will never work due to zero-bits of trueness:
start (with and without /wait) have sense in bat-file only if you have more than one bat-process starting from this bat (compare with call), for called GUI it doesn't differ from direct using program-name
TortoiseProc is GUI-app after all, it emits nothing to stdout
Info was and is unknown command for TortoiseProc, thus you'll get only GUI-window "About"
:about Shows the about dialog. This is also shown if no command is
given
In addition to correct suggestion "Update to at least 1.8 on client and have CLI-tools" you can consider following solutions:
Install from unrelated to TortoiseSVN sources pure CLI SVN-client (also 1.6.* - from WanDisco will be good choice) at the same as TSVN or another location (I done it at the times of 1.6)
Study and use subwcrev (it was part of TortoiseSVN even in 1.6, AFAICR) and emulate some part of svn info in subwcrev's template-file with correct keywords

Post-build arguments to batch script fails to convert build parameter

I'm using TFS 2013 and am building an Azure Cloud Service project that I want to package with Nuget so that I can publish to Octopus Deploy. I can't use octopack, because at the moment this is not supported. I'm trying to pass TFS parameters into a post-build batch script so that I can run nuget with -version parameters (which should change with each build).
The problem I'm having is that the batch script does not recognise the TFS build parameters. for example, in the script I want to pass an argument version $(TeamProject)-1.0.0$(Rev:.r), that would give the script the version to set in the package name.
The full nuget package call in the script is:
%nugetPath% push %packagePath%\Veedyo.%version%.nupkg
Passing this into the post-build script path works:
$/Application1/MAIN/Source/.NET/Application1.Package/package.cmd
This is because the source control path is translated into an actual path just after the build completes (and I can see the real path in the log).
However, the Post-build script arguments property in the build, doesn't convert this "$(TeamProject)"-1.0.0"$(Rev:.r)" to the desired value. this leads to an error executing the batch script:
Exception Message: TF270015: 'package.cmd' returned an unexpected exit code. Expected '0'; actual '1'. See the build logs for more details
So, does anyone have any idea how to convert add build parameter to the post-build script arguments property?
These macros are not available when you run the script. You can use one the the TF_BUILD environment variables listed here.
Probably, you are looking for TF_BUILD_BUILDNUMBER, or maybe you have to extract the data you are looking for; in this latter case Powershell can be simpler to use than cmd.exe interpreter.

Resources