TopLevelItem newJob = Jenkins.getInstance().createProject(jobClass, newName);
if (newJob != null && newJob instanceof BuildableItemWithBuildWrappers) {
// If the target job (jobToClone) is actually a template, let's implement it rather than just clone it.
BuildableItemWithBuildWrappers buildable = (BuildableItemWithBuildWrappers) newJob;
DescribableList<BuildWrapper, Descriptor<BuildWrapper>> buildWrappersList = buildable.getBuildWrappersList();
TemplateBuildWrapper toRemove = BuildWrapperUtils.findBuildWrapper(TemplateBuildWrapper.class, buildable);
buildWrappersList.remove(toRemove);
String variablesAsPropertiesFile = squashVariables(variableValues);
ImplementationBuildWrapper implementationBuildWrapper = new ImplementationBuildWrapper(jobToClone.getName(), newJob.getName(), variablesAsPropertiesFile);