Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basics: how to create templates with Template Project Plugin in Jenkins?

I'm missing something very basic. I have Jenkins 1.607 and recently installed Template Project Plugin 1.5.1 but don't see a way to create templates. This is what I see, when I select New Job:

enter image description here

There is Workflow Template above, but no Project Template. I'm not sure what I should be looking for...

Searching online I found the following (http://mark.gg/2013/05/03/jenkins-and-templates/):

"To use the template plugin, you create a job that will have modules - source code management (SCM), builders, publishers - that will be used by other projects."

However, following instructions from the above page, Jenkins creates a regular job - I don't see a way to specify modules. Here is the SCM section in my job that should become a template:

Template job SCM section

New Edit: ==>> I have several jobs with SCM section defined. Below is a newly created, Freestyle job where I want to use the SCM from an already defined job, but there is no such choice:

New job where I want to use SCM template

For the record, here is a snapshot of installed template plugins:

Installed Template Plugins

Appreciate any pointers on how to "create a job that will have modules".

Edit: upgraded Jenkins to the latest 1.631 - same problem.

like image 916
Lidia Avatar asked Sep 26 '15 06:09

Lidia


2 Answers

The template project is a classic Jenkins job. In this job, please define all the module you want to use in clone jobs (SCM, build, post build, ...):

enter image description here

enter image description here

enter image description here

Next, create a new job and select the template modules:

enter image description here

enter image description here

enter image description here

Does it solve your problem? :)

like image 111
Bruno Lavit Avatar answered Nov 13 '22 03:11

Bruno Lavit


I installed Jenkins 1.638 and ran into the same problem using an SCM template from an already defined job because it didn't show up in the option list. Digging deeper the "System Log" in the "Manage Jenkins" section had some more information as to why.

Nov 13, 2015 3:22:53 PM INFO jenkins.InitReactorRunner$1 onAttained
Augmented all extensions

Nov 13, 2015 3:22:58 PM WARNING hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 error

Failed to instantiate Key[type=hudson.plugins.templateproject.ProxySCM$DescriptorImpl, annotation=[none]]; skipping this component
com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: org/jenkinsci/plugins/multiplescms/MultiSCMRevisionState
  at hudson.plugins.templateproject.ProxySCM$DescriptorImpl.<init>(ProxySCM.java:112)

Turns out there is a dependency on the plugin "Multiple SCMs Plugin". Install that plugin and the option shows up correctly in the Jenkins job configuration using the version 1.5.1 of the Template Project plugin.

SCM Options Before installing the Multiple SCM Plugin

SCM Options After installing the Multiple SCM Plugin

like image 20
Bluefishzx Avatar answered Nov 13 '22 04:11

Bluefishzx