TeamCity - start tomcat - batch-file

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.

Related

KNIME Command Line Execution - ClassNotFoundException

I'd like to schedule a KNIME workflow. The workflow does its job very good as long as I start it from the KNIME GUI application. When I execute the same workflow via command line, java complains that com.microsoft.sqlserver.jdbc.SQLServerDriver
could not be found (ClassNotFoundException).
I invoke it via:
"D:\Progamme\KNIME\knime.exe" -nosplash -application -consoleLog org.knime.product.KNIME_BATCH_APPLICATION -preferences="absolutepathto\preferences.epf" -workflowDir="absolutepathto\workflow"
Since the error message signals missing content in the java CLASSPATH I also tried to add the parameters
-vmargs -classpath .;"absolutepathto/sqljdbc42.jar"
But still I earn a java slap, pointing to the same error...
I also tried to run the command from within the knime.exe's directory and I also tried to add the JAR file to Preferences -> Java -> Build Path -> Classpath Variable / User Libraries (referenced via the -preference argument). But that had no effect.
Did anybody face the same problems? Maybe with other third party JARs?
It is all about a Database connector that is configured like this:
Does the integrated security maybe force a misleading error?
System spec: KNIME 3.2.2 on Windows Server 2008 R2
Update - extract from preferences file
/configuration/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
/configuration/org.eclipse.ui.ide/MAX_RECENT_WORKSPACES=10
/configuration/org.eclipse.ui.ide/RECENT_WORKSPACES=<list of some workspaces>
/configuration/org.eclipse.ui.ide/RECENT_WORKSPACES_PROTOCOL=3
/configuration/org.eclipse.ui.ide/SHOW_RECENT_WORKSPACES=false
/configuration/org.eclipse.ui.ide/SHOW_WORKSPACE_SELECTION_DIALOG=true
Is there maybe a problem due to the fact that it is a shared KNIME instance among several users and the command line execution does not know which workspace has to be chosen? Is the workspace somehow needed and why?
Partial Solution:
I finally managed it but I don't know exactly why it works now. What I did was to load a fresh portable version of KNIME and ran the same commands only changing the executable path to the new portable version. Before that I started the portable version once to set the workspace directory and register the database driver in preferences dialog and .ini file, nothing else, same configuration so far as the shared KNIME instance. What I am really wondering abpout is that from now on the commands are also working with the shared KNIME instance. I really don't know what caused the change that let KNIME find the driver class.
Info
Because I encountered a few more problems within shared environment in KNIME command line mode, that led to undeterministic execution results, I wrote a little .NET library. This gives me more flexibility/control over the workflow execution (which returncodes and error messages occured and so on). You can find it here if you're interested: KnimeNet
I took a very minimal approach:
cd "C:\Program Files\KNIME"
.\knime -nosplash -noexit -consoleLog -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowFile="D:\Work\Knime Workflows\Output\CMD_Test.knwf" -preferences="D:\Work\Knime Workflows\Output\CMD_Test.epf"

Jenkins parameter is getting replaced by a white space

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!!!

How to trigger a batch file in Jenkins without waiting for batch execution results and status

I have a Jenkins job which is building /packaging/ deploying .NET project. I use "Clean Before checkout" git property for each build.
Finally, I'm executing a batch file. This batch file scanning sonar Qube MSBuild, c# analysis and update the code quality results. But It is taking a long time and I don't want to increment Jenkins job's total execution time from 1 minute to 5 minutes. Developers are thinking so the deployment is taking a long time and not finished yet.
I want to run this batch file independent from the Jenkins job and don't want to see the console output in Jenkins. How could I do this without creating a new Jenkins job for each Jenkins project (upstream/downstream projects)
you need to use the start cmd command,for example:
start YourBatch.bat
This will open a new CMD window and Jenkins won't wait for result.
Bare in mind that if you get an exit code different than 0, it won't fail the build.

Getiing error message 'Failed Installing JBAS50SVC' whle running service.bat file in Windows 7

I need to run Jboss 7 as service.
Followed these steps :-
Copied my Jboss to C:\Program Files <86>
Downloaded Jboss-native-2.0.10-windows-x64-ssl and copied the contenst of bin catalog to %JBOSS_HOME%/bin
Changes done on service.bat as per link instructions
https://community.jboss.org/message/724488
Changed my dir location to my Jboss bin
and given command service.bat install
C:\Program Files \jboss7>bin>service.bat install
Failed installing JBAS50SVC
Access is Denied.
Service JBoss Application Server 7.1.1 installed.
I'm not able to rectify this problem .
It appears to be windows access issue.
Try the following:
Does the windows ID you are using have Administrator privileges? If no, get a Admin ID else if Yes, proceed to step 2.
Try to do the same but in some other drive (not c: )
UPDATE #1 : OP says he can not see the output of service.bat file
Follow the following steps
Open start menu
Search for "cmd"
Right click "cmd" and run as Administrator
type in following command
cd C:\Program Files \jboss7\bin
Type service.bat and observe the output
On a 2008 Windows Server this occurs because you're not running the command line as an administrator. Those of us who have spent considerable amounts of time on 2003 server, and others before that, keep forgetting that your logged in ADMIN level account does NOT get passed to the command line automatically like with previous versions of Windows.
With any additional errors, past this one, I would keep going back to the service.bat file and looking at the path statements, throughout that file, to ensure that they are all correct to reach what is correct for your installation.
Also, don't forget to create a log folder under standalone (unless you're doing a domain install). Failure to do that will also cause issues as well.
yoda

Vagrant Up or Provision if already Up

I need to create a simple script (Windows .bat) that will provision or up a box.
Not much experience with .bat files, so this is what I have so far:
Edited thanks to Greg Hewgill
cd C:\vagrant-box\
call vagrant-up.bat
if errorlevel 1 call vagrant-provision.bat
The .bat files called in the script just contain one line: vagrant up and vagrant reload, respectively.
When the vagrant box is down, then vagrant up runs successfully. When up, I encounter an error with vagrant up (which I expect) but the whole batch file dies there. ErrorLevel doesn't appear to do anything.
Here is the error if it makes a difference
Bringing machine 'default' up with 'virtualbox' provider...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["list", "hostonlyifs"]
Stderr: VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Code CO_E_SERVER_EXEC_FAILURE (0x80080005) - Server execution failed (extend)
VBoxManage.exe: error: Most likely, the VirtualBox COM server is not running or failed to start.
I want to emphasize I don't care about the error per se. It works when the box is not running, so it's fine. I just want to capture or ignore it, and move to the next command.
vagrant up exits with code 0 even if the machine is already running.
But you don't have to bother with exit codes, you can just run:
vagrant provision && vagrant up
And you should cover both cases. If the guest is not running, vagrant provision will gracefully fail and vagrant up will succeed, and vice versa.
Please post your vagrant-up.bat.
Also, try either this:
vagrant up --debug
and/or
VAGRANT_LOG=debug vagrant <action>
To get more detais about the COM/VBox issue.

Resources