How to create a job to run command line job from Jenkins (window)

6,408 views
Skip to first unread message

Lily Fu

unread,
Feb 11, 2014, 5:43:22 PM2/11/14
to jenkins...@googlegroups.com

Hi,

 

I am running Jenkins on Window7 now for testing purpose.

 

I have a command line job (liquibase to compare two databases)

 

I want to run the command line job twice a day ;

 

How can I create such a job in Jenkins?

(basically like a cron job on linux)

 

Thanks!

 

Lily

Les Mikesell

unread,
Feb 11, 2014, 6:06:54 PM2/11/14
to jenkinsci-users
On Tue, Feb 11, 2014 at 4:43 PM, Lily Fu <Lil...@nesassociates.com> wrote:
>
> I am running Jenkins on Window7 now for testing purpose.

Keep in mind that jenkins jobs don't necessarily have to run on the
server - and the slaves don't have to have the same OS - even if you
start on a single machine.

> I have a command line job (liquibase to compare two databases)
>
> I want to run the command line job twice a day ;
>
> How can I create such a job in Jenkins?

Click the 'new job' link and create a free-style project.

> (basically like a cron job on linux)

Under 'Build triggers' check 'build periodically' and fill in the
schedule with the cron-like syntax that is explained if you click the
? symbol. Something like 0 1,13 * * * would run at 1 am and 1 pm.

Then add a build step to execute a windows batch command to do the work.

Did you try this and run into some problem?

--
Les Mikesell
lesmi...@gmail.com

Lily Fu

unread,
Feb 11, 2014, 6:17:43 PM2/11/14
to jenkins...@googlegroups.com
Thanks for your reply,
I am very new with Jenkins, so please excuse me for dummy questions:

Yes, I created a free style job, scheduled to run at certain time, and added a command line job (tested)
I got:
(looks like the job was started by user anonymous, maybe the command liquibase is not available for this user?
I tested a job for a simple ' dir c:\' it worked OK)


Started by user anonymous
Building in workspace C:\Users\lily.fu\.jenkins\jobs\LilyTest_LiquibaseDiff\workspace
[workspace] $ sh -xe C:\windows\TEMP\hudson2336063048912468753.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "C:\Users\lily.fu\.jenkins\jobs\LilyTest_LiquibaseDiff\workspace"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
at hudson.Launcher$ProcStarter.start(Launcher.java:353)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:784)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:565)
at hudson.model.Run.execute(Run.java:1670)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 16 more
Build step 'Execute shell' marked build as failure
Finished: FAILURE
--
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 jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Les Mikesell

unread,
Feb 11, 2014, 6:25:37 PM2/11/14
to jenkinsci-users
On Tue, Feb 11, 2014 at 5:17 PM, Lily Fu <Lil...@nesassociates.com> wrote:
> Thanks for your reply,
> I am very new with Jenkins, so please excuse me for dummy questions:

No problem, but it helps to include the details.

> Yes, I created a free style job, scheduled to run at certain time, and added a command line job (tested)
> I got:
> (looks like the job was started by user anonymous, maybe the command liquibase is not available for this user?
> I tested a job for a simple ' dir c:\' it worked OK)
>
>
> Started by user anonymous
> Building in workspace C:\Users\lily.fu\.jenkins\jobs\LilyTest_LiquibaseDiff\workspace
> [workspace] $ sh -xe C:\windows\TEMP\hudson2336063048912468753.sh

That looks like you picked a build step of 'execute shell'
(appropriate for unix/linux) instead of 'execute windows batch
command' which you need in a windows environment.

--
Les Mikesell
lesmi...@gmail.com

Lily Fu

unread,
Feb 11, 2014, 6:28:08 PM2/11/14
to jenkins...@googlegroups.com
Wonderful hint!!!

Yes, successful!

Thank you so much!!!

Lily

-----Original Message-----
From: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com] On Behalf Of Les Mikesell
Sent: Tuesday, February 11, 2014 6:26 PM
To: jenkinsci-users
Subject: Re: How to create a job to run command line job from Jenkins (window)

Reply all
Reply to author
Forward
0 new messages