job creation via jenkins cli

3,232 views
Skip to first unread message

Eugene Sajine

unread,
Jan 19, 2012, 5:29:04 PM1/19/12
to jenkins...@googlegroups.com
Hi,

I need help here!

I have about 600 jobs in Jenkins and I have the process of creating
the job automated. I'm creating the config.xml file for the job with
all necessary parameters changed depending on the particular project
and then I'm creating new folder in Jenkins jobs folder with this
config file in place.
After that I'm forced to reload the server environment in order to
pick up new job.
The problem with this approach is obvious - reload takes a lot of
time, i have to maintain a cron job that polls the amount of jobs has
changed and it all makes it cumbersome. Plus i have two instances of
jenkins and one of them is using promotion plugin, so because of
promotion plugin being so special and having separate config file i
have to also create this file for the new job in specific folder and
then reload the environment to pick up the new job.

Now I know there is an option to create the job via cli by providing
the XMl file in STDIN. The problem is I cannot understand how it
supposed to work?
I'm trying to provide path to the xml file (like this : java -jar
jenkins-cli.jar -s http://myserver:port create-job myname
path/to/the/config.xml) - it fails with "Too many arguments". What
this command expects user to do?
How can i pass xml file content to this from another program other
than a file name? I tried to use a stream - it doesn't work...

Another problem that i kind of foresee - promotion plugin and the fact
that this plugin suddenly has its own configuration file in its own
place??? I don't think it supposed to happen in a first place, but
nonetheless if it happened how am i supposed to configure new job via
cli with promotion plugin???

May be there are better ways of automating job submissions? Please advise!

Thanks!

Sami Tikka

unread,
Jan 19, 2012, 6:30:40 PM1/19/12
to jenkins...@googlegroups.com
java -jar -cli.jar -s http://myserver:port create-job myname path/to/the/config.xml

Add a less-than before the path name. 

java -jar -cli.jar -s http://myserver:port create-job < myname path/to/the/config.xml

-- Sami

Eguess

unread,
Jan 19, 2012, 10:49:24 PM1/19/12
to Jenkins Users
Thanks! I'll try that.
Seems like there is still a question about the promotion plugin
configuration via cli...

On Jan 19, 6:30 pm, Sami Tikka <sjti...@gmail.com> wrote:
> > java -jar -cli.jar -shttp://myserver:portcreate-job myname path/to/the/config.xml
>
> Add a less-than before the path name.
>
> > java -jar -cli.jar -shttp://myserver:portcreate-job < myname path/to/the/config.xml
>
> -- Sami
>
> Eugene Sajine <eugu...@gmail.com> kirjoitti 20.1.2012 kello 0.29:
>
>
>
>
>
>
>
> > Hi,
>
> > I need help here!
>
> > I have about 600 jobs in Jenkins and I have the process of creating
> > the job automated. I'm creating the config.xml file for the job with
> > all necessary parameters changed depending on the particular project
> > and then I'm creating new folder in Jenkins jobs folder with this
> > config file in place.
> > After that I'm forced to reload the server environment in order to
> > pick up new job.
> > The problem with this approach is obvious - reload takes a lot of
> > time, i have to maintain a cron job that polls the amount of jobs has
> > changed and it all makes it cumbersome. Plus i have two instances of
> > jenkins and one of them is using promotion plugin, so because of
> > promotion plugin being so special and having separate config file i
> > have to also create this file for the new job in specific folder and
> > then reload the environment to pick up the new job.
>
> > Now I know there is an option to create the job via cli by providing
> > the XMl file in STDIN. The problem is I cannot understand how it
> > supposed to work?
> > I'm trying to provide path to the xml file (like this : java -jar
> > jenkins-cli.jar -shttp://myserver:portcreate-job myname
Reply all
Reply to author
Forward
0 new messages