Running a bat file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Running a bat file

harvey
Hi,

I am trying to run a bat file to start a server and I used the following script:

cd c:\...\bin
call asadmin start-domain

But I see that Jenkins isn't waiting for the batch script to exhibit.

I would be thankful, if you could guide me in this regard.

Regards,
Harvey

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/27491f4b-13df-4afb-a3f5-878acf1cef93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running a bat file

jerome-2
Take care that you are actually chaining batch command. What is chaining batch, someone somewhere though it would be nice to make this super weird feature for batch script only (yeah a lot of sarcasm here, the first time you see this beahavior and realize wtf someone wanted to do this is beyond total common sense), where you call a batch from another batch script, the remaining in between one can be skipped entirely. Here's the documentation from https://jpsoft.com/help/call.htm which give a better explanation of this eye bleeding nightmare:

WARNING! If you execute a batch file from inside another batch file without using CALL, the original batch file is terminated before the other one starts. This method of invoking a batch file from another is usually referred to as chaining. Note that if the batch file A.BTM uses CALL B, and B.BTM chains to the batch file C.BTM, on exit from C.BTM (without executing a CANCEL command) processing of batch file A.BTM is resumed as if it had used CALL C.

I suspect that the Jenkins shell execute the script you gave it as it is a call itself maybe, maybe the Jenkins people can shed some light on this.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d6337c9f-723b-48fb-b7f5-c13283deb708%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running a bat file

harvey


On Tuesday, September 12, 2017 at 7:21:55 PM UTC+2, [hidden email] wrote:
Take care that you are actually chaining batch command. What is chaining batch, someone somewhere though it would be nice to make this super weird feature for batch script only (yeah a lot of sarcasm here, the first time you see this beahavior and realize wtf someone wanted to do this is beyond total common sense), where you call a batch from another batch script, the remaining in between one can be skipped entirely. Here's the documentation from <a href="https://jpsoft.com/help/call.htm" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcall.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEAVQq0ihQ4a4erHlJtL18fOv1pJA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcall.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEAVQq0ihQ4a4erHlJtL18fOv1pJA&#39;;return true;">https://jpsoft.com/help/call.htm which give a better explanation of this eye bleeding nightmare:

WARNING! If you execute a batch file from inside another batch file without using CALL, the original batch file is terminated before the other one starts. This method of invoking a batch file from another is usually referred to as chaining. Note that if the batch file A.BTM uses CALL B, and B.BTM chains to the batch file C.BTM, on exit from C.BTM (without executing a <a href="https://jpsoft.com/help/cancel.htm" style="vertical-align:baseline;color:blue" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcancel.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJ0WIR1wN1Z5ATQTbdQ7MHnOx36w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcancel.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJ0WIR1wN1Z5ATQTbdQ7MHnOx36w&#39;;return true;">CANCEL command) processing of batch file A.BTM is resumed as if it had used CALL C.

But I am using CALL to run the other batch file. The problem is when I run the build, it is completed successfully. But the server is still not started. The commands works great in CMD and also I tried creating a batch file and even it works fine. And again I tried calling the batch file I created into Jenkins, yet there was no success. The problem still remained and the server was still not started.


I suspect that the Jenkins shell execute the script you gave it as it is a call itself maybe, maybe the Jenkins people can shed some light on this.


Regards,
Harvey

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2a2020e0-eea1-433c-8363-89b6467a135d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running a bat file

harvey


On Wednesday, September 13, 2017 at 11:20:55 AM UTC+2, harvey wrote:


On Tuesday, September 12, 2017 at 7:21:55 PM UTC+2, [hidden email] wrote:
Take care that you are actually chaining batch command. What is chaining batch, someone somewhere though it would be nice to make this super weird feature for batch script only (yeah a lot of sarcasm here, the first time you see this beahavior and realize wtf someone wanted to do this is beyond total common sense), where you call a batch from another batch script, the remaining in between one can be skipped entirely. Here's the documentation from <a href="https://jpsoft.com/help/call.htm" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcall.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEAVQq0ihQ4a4erHlJtL18fOv1pJA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcall.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEAVQq0ihQ4a4erHlJtL18fOv1pJA&#39;;return true;">https://jpsoft.com/help/call.htm which give a better explanation of this eye bleeding nightmare:

WARNING! If you execute a batch file from inside another batch file without using CALL, the original batch file is terminated before the other one starts. This method of invoking a batch file from another is usually referred to as chaining. Note that if the batch file A.BTM uses CALL B, and B.BTM chains to the batch file C.BTM, on exit from C.BTM (without executing a <a href="https://jpsoft.com/help/cancel.htm" style="vertical-align:baseline;color:blue" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcancel.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJ0WIR1wN1Z5ATQTbdQ7MHnOx36w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjpsoft.com%2Fhelp%2Fcancel.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJ0WIR1wN1Z5ATQTbdQ7MHnOx36w&#39;;return true;">CANCEL command) processing of batch file A.BTM is resumed as if it had used CALL C.

But I am using CALL to run the other batch file. The problem is when I run the build, it is completed successfully. But the server is still not started. The commands works great in CMD and also I tried creating a batch file and even it works fine. And again I tried calling the batch file I created into Jenkins, yet there was no success. The problem still remained and the server was still not started.


I suspect that the Jenkins shell execute the script you gave it as it is a call itself maybe, maybe the Jenkins people can shed some light on this.


Regards,
Harvey

By using the following link: https://wiki.jenkins.io/display/JENKINS/ProcessTreeKiller, I edited the command as follows:

cd c:\glassfish3\bin\
asadmin start-domain
$BUILD_ID=dontKillMe

But it didn't solve my problem though. I am sure that this is not the way. I am new user to Jenkins, I have no idea about using environment variables. Any help would be appreciated, I am blocked at this stage, would be grateful if anyone could guide me in this regard.

Regards,
Harvey

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a3b7ef0b-1fbb-4bbc-b8a6-1cda2df84f1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running a bat file

jerome-2
In reply to this post by harvey
I'm not sure if you are using pipeline or not, either way, when you said the command succeed, the fact that a batch complete doesn't make it successful, make sure to evaluate the %errorlevel%  after critical command. ALso if you are using pipeline, make sure to check if the returnStatus and returnStdout to make sure you can fetch some information.

Also, I'm not sure if asadmin can be run by your jenkins service (make sure it got permission to do so). If Jenkins is installed as a service, take care no GUI can be launch from that user. If your start-domain use any gui, you will need to run your Jenkins as a real user and keep that user login under Windows. 
Also does the asadmin is available into the PATH of your jenkins user, may want to provide a full path.

If you can give more meat around the way you run your batch command and some console output that would help to help you.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d4242e34-d82e-4a3e-b027-c05c03c6f972%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running a bat file

harvey
Currently I am just trying to create a single build to Start the glassfish server. For the same I used a freestyle project and by selecting "Run a batch windows command line" in building steps I wrote the following commands:

cd c:\glassfish3\bin
call asadmin start-domain

Then I saved the build and executed it. The build completes with status success, but the glassfish server remain unstarted.

Other than these steps I haven't done any other steps. I did not set an ERROR LEVEL.

Is there something I am missing ?

Regards,
Harvey

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d303caf3-7f66-4f2e-a604-360819d8288d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running a bat file

t3knoid
Have you looked at using the Start command? As I understand it, it starts a process in a different context. In this way, when the Jenkins job ends, it doesnt shut down the service since its in a different context.

On Friday, September 15, 2017 at 4:01:58 AM UTC-4, harvey wrote:
Currently I am just trying to create a single build to Start the glassfish server. For the same I used a freestyle project and by selecting "Run a batch windows command line" in building steps I wrote the following commands:

cd c:\glassfish3\bin
call asadmin start-domain

Then I saved the build and executed it. The build completes with status success, but the glassfish server remain unstarted.

Other than these steps I haven't done any other steps. I did not set an ERROR LEVEL.

Is there something I am missing ?

Regards,
Harvey

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/bf19be64-6f59-4c90-a152-91c97d240985%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.