Parametrized build for E2E testing in different environments

27 views
Skip to first unread message

Alberto Scotto

unread,
May 28, 2020, 1:11:56 PM5/28/20
to Jenkins Users
Hi,

Long story short: is it possible to have a job which builds another job, in particular a parametrized one?

We have a Cucumber+Selenium project which runs E2E tests against our different test environments.
Something pretty standard.

For this kind of job, the parametrized build seems to be the best idea.
Otherwise we would have to create one job for each test environment. duplicating the job configuration.
Then it would be a nightmare to keep all the job configurations in sync, in case we need to change something.

But there's a problem with the build history.
I want to see a separate build history for each environment.
It doesn't make sense to have an interleaved history. It would be messy.

So an easy solution could be to have a job which calls the parametrized job passing the actual value for the environment.
This way the build histories would be kept separate, and at the same time we would also get to avoid duplication.

Is that possible? Or do you have any other idea/solution?

Thank you very much.

Alberto

Eric Pyle

unread,
May 28, 2020, 6:17:42 PM5/28/20
to jenkins...@googlegroups.com
Assuming you are using a Freestyle project (not Pipeline) you could use the Template Project Plugin https://plugins.jenkins.io/template-project/. You create a template job which contains all the common functionality, and then in the separate job for each environment you add the template job as a build step (Use builders from another project).

-Eric
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5f64c8d1-db57-4002-9aa7-5e574638b76c%40googlegroups.com.

Alberto Scotto

unread,
Jun 4, 2020, 11:42:09 AM6/4/20
to Jenkins Users
Thanks Eric, I appreciate it.
Unfortunately the template plugin seems not be up-to-date.
I've just opened a new issue on JIRA, but I'm not really hopeful..

I noticed there seems to be a couple more template plugins, I might give them a try.

Assuming you are using a Freestyle project (not Pipeline)

What if we were to use Pipeline? Would it make things easier?


Thank you

Alberto
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.

Eric Pyle

unread,
Jun 4, 2020, 11:53:39 AM6/4/20
to jenkins...@googlegroups.com
Using Pipeline you would take a different approach, like having a common script in source control that all the jobs could use to accomplish the common task.

I'm surprised that the Template plugin is not working for you, however. We're not at the very latest LTS but at 2.204.5, and it works fine for us. We use it in hundreds of jobs. A quick look at your stack trace suggests you are missing the Multiple SCM plugin as a dependency.

Regards,
Eric
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b75ccb32-b748-4af1-8331-ace29a2c6074%40googlegroups.com.

Alberto Scotto

unread,
Jun 4, 2020, 12:30:11 PM6/4/20
to Jenkins Users
I see thanks!

I never really had the chance to look into pipelines, but now the time might have come.
Deprecated: Users should migrate to https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin
 
Anyway, back to the template plugin,
after installing the Multiple SCMs plugin now I can see the checkbox "Use build environment from another project", but I still can't seem to get it to work.
In the jobs console output I have:

Started by user admin
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\asd
[TemplateProject] Starting pre-checkout from: E2E Template
[TemplateProject] Successfully performed pre-checkout from: 'E2E Template'
Cloning the remote Git repository
[..]
[TemplateProject] Getting environment from: E2E Template
[TemplateProject] Successfully setup environment from: 'E2E Template'
Finished: SUCCESS

Any idea what could be wrong?
 

Eric Pyle

unread,
Jun 4, 2020, 3:52:46 PM6/4/20
to jenkins...@googlegroups.com
Go to the Build section of the job config, and add a build step of type "Use builders from another project". Your job will now use all the Build steps configured in the other job you specify there.

The configuration you added would use the "Build Environment" settings from the job you specified, which may also be useful, but I think you were looking for build steps.

Regarding Multiple SCM plugin, that is indeed deprecated, and I don't recommend using it directly.

-Eric
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/25e331fc-9c59-4490-874d-6feab43a2504%40googlegroups.com.

Alberto Scotto

unread,
Jun 4, 2020, 6:55:53 PM6/4/20
to Jenkins Users
Thanks, works now!

I was also reading about the pipeline, and I've found out that it's based upon the old plugin Build Flow, which used to do exactly what I was hoping for:

You can pass parameters to jobs, and get the resulting AbstractBuild when required :

b = build( "job1", param1: "foo", param2: "bar" )
build( "job2", param1: b.build.number )

Yet another sign the pipeline is the best way to go.

Thank you very much Eric,

Alberto

Reply all
Reply to author
Forward
0 new messages