当前位置: 首页>>代码示例>>Java>>正文


Java SCM类代码示例

本文整理汇总了Java中hudson.scm.SCM的典型用法代码示例。如果您正苦于以下问题:Java SCM类的具体用法?Java SCM怎么用?Java SCM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SCM类属于hudson.scm包,在下文中一共展示了SCM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onChange

import hudson.scm.SCM; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onChange(Saveable o, XmlFile file) {
    if (!(o instanceof Item)) {
        // must be an Item
        return;
    }
    SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem((Item) o);
    if (item == null) {
        // more specifically must be an SCMTriggerItem
        return;
    }
    SCMTrigger trigger = item.getSCMTrigger();
    if (trigger == null || trigger.isIgnorePostCommitHooks()) {
        // must have the trigger enabled and not opted out of post commit hooks
        return;
    }
    for (SCM scm : item.getSCMs()) {
        if (scm instanceof GitSCM) {
            // we have a winner
            GiteaWebhookListener.register(item, (GitSCM) scm);
        }
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:27,代码来源:GiteaWebhookListener.java

示例2: isMatch

import hudson.scm.SCM; //导入依赖的package包/类
@Override
public boolean isMatch(@NonNull SCM scm) {
    if (scm instanceof GitSCM && !disableNotifyScm) {
        GitSCM git = (GitSCM) scm;
        if (git.getExtensions().get(IgnoreNotifyCommit.class) != null) {
            return false;
        }
        for (RemoteConfig repository : git.getRepositories()) {
            for (URIish remoteUri : repository.getURIs()) {
                if (GitStatus.looselyMatches(this.remoteUri, remoteUri)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:18,代码来源:GitPubSubPoll.java

示例3: getBranch

import hudson.scm.SCM; //导入依赖的package包/类
private String getBranch(SCM scm) {
    if (scm instanceof GitSCM) {
        GitSCM gitScm = (GitSCM) scm;
        StringBuilder builder = new StringBuilder();
        for (BranchSpec spec : gitScm.getBranches()) {
            if (builder.length() > 0) {
                builder.append(", ");
            }
            builder.append(spec.getName());
        }

        return builder.toString();
    }

    // here we can try to get branch from other SCM
    return "undetermined";
}
 
开发者ID:Microsoft,项目名称:vsts-jenkins-build-integration-sample,代码行数:18,代码来源:TfsBuildFacadeFactoryImpl.java

示例4: jobLoaded

import hudson.scm.SCM; //导入依赖的package包/类
@Initializer(before = InitMilestone.COMPLETED, after = InitMilestone.JOB_LOADED)
public static void jobLoaded() throws IOException
{
	m_logger.fine("Initialization milestone: All jobs have been loaded"); //$NON-NLS-1$
	Jenkins jenkins = Jenkins.getInstance();
	for (AbstractProject<?, ?> project : jenkins.getAllItems(AbstractProject.class))
	{
		try
		{
			SCM scmConfig = project.getScm();
			if (scmConfig instanceof AbstractConfiguration && ((AbstractConfiguration) scmConfig).isMigrated())
			{
				project.save();

				m_logger.info(String.format(
								"Project %s has been migrated.", //$NON-NLS-1$
								project.getFullName()));
			}
		}
		catch (IOException e)
		{
			m_logger.log(Level.SEVERE, String.format("Failed to upgrade job %s", project.getFullName()), e); //$NON-NLS-1$
		}
	}
}
 
开发者ID:jenkinsci,项目名称:compuware-scm-downloader-plugin,代码行数:26,代码来源:AbstractConfiguration.java

示例5: newInstance

import hudson.scm.SCM; //导入依赖的package包/类
@Override
public SCM newInstance(final StaplerRequest req,
                       final JSONObject formData) throws FormException {
    return new AWSCodePipelineSCM(
            req.getParameter("name"),
            req.getParameter("clearWorkspace") != null,
            req.getParameter("region"),
            req.getParameter("awsAccessKey"),
            req.getParameter("awsSecretKey"),
            req.getParameter("proxyHost"),
            req.getParameter("proxyPort"),
            req.getParameter("category"),
            req.getParameter("provider"),
            req.getParameter("version"),
            new AWSClientFactory());
}
 
开发者ID:awslabs,项目名称:aws-codepipeline-plugin-for-jenkins,代码行数:17,代码来源:AWSCodePipelineSCM.java

示例6: createSCM

import hudson.scm.SCM; //导入依赖的package包/类
@Override
protected SCM createSCM() {
	P4WebBrowser browser = null;

	Workspace workspace = null;
	if (notNull(stream))
		workspace = new StreamWorkspaceImpl(charset, false, stream, format);
	else if (notNull(template))
		workspace = new TemplateWorkspaceImpl(charset, false, template,
				format);
	else if (notNull(depotPath)) {
		String view = depotPath + "/..." + " " + "//" + format + "/...";
		WorkspaceSpec spec = new WorkspaceSpec(false, false, false, false,
				false, false, null, "local", view);

		workspace = new ManualWorkspaceImpl(charset, false, format, spec);
	}

	// TODO: add populate options?
	Populate populate = new AutoCleanImpl(true, true, false, false, null);

	PerforceScm scm = new PerforceScm(credential, workspace, null,
			populate, browser);

	return scm;
}
 
开发者ID:p4paul,项目名称:p4workflow,代码行数:27,代码来源:P4Step.java

示例7: annotate

import hudson.scm.SCM; //导入依赖的package包/类
/**
 * Annotate the changelog text to point to changelog overview.
 * 
 * @param build
 * @param change
 * @param text 
 */
public void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text ){
   SCM scm  = build.getProject().getScm(); 
   
   if (scm instanceof FossilScm) {
       FossilScm fscm = (FossilScm) scm;
       
       String url = fscm.getServerUrl();
       
       if (!url.endsWith("/")){
           url = url + "/";
       }
       url = url + "info/" + change.getCommitId();
       text.addHyperlink(0, text.length(), url);
   }
   
}
 
开发者ID:rjperrella,项目名称:jenkins-fossil-adapter,代码行数:24,代码来源:FossilChangeLogAnnotator.java

示例8: SingleTestFlakyStatsWithRevision

import hudson.scm.SCM; //导入依赖的package包/类
/**
 * Construct a SingleTestFlakyStatsWithRevision object with {@link SingleTestFlakyStats} and
 * build information.
 *
 * @param stats Embedded {@link SingleTestFlakyStats} object
 * @param build The {@link hudson.model.AbstractBuild} object to get SCM information from.
 */
public SingleTestFlakyStatsWithRevision(SingleTestFlakyStats stats, AbstractBuild build) {
  this.stats = stats;
  revision = Integer.toString(build.getNumber());

  SCM scm = build.getProject().getScm();
  if (scm != null && scm instanceof GitSCM) {
    GitSCM gitSCM = (GitSCM) scm;
    BuildData buildData = gitSCM.getBuildData(build);
    if (buildData != null) {
      Revision gitRevision = buildData.getLastBuiltRevision();
      if (gitRevision != null) {
        revision = gitRevision.getSha1String();
      }
    }
  }
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:24,代码来源:HistoryAggregatedFlakyTestResultAction.java

示例9: loadConfigFromSCM

import hudson.scm.SCM; //导入依赖的package包/类
/**
 * This method loads files from SCM
 */
public void loadConfigFromSCM() {
    try {
        SCM scm = this.getScm();
        if (scm == null || scm instanceof NullSCM) {
            return;
        }
        FilePath checkoutDir = new FilePath(Files.createTempDirectory("leroyTempDir").toFile());
        AbstractBuild dumbBuild = new NewBuild(this);
        Launcher dumbLauncher = Hudson.getInstance().createLauncher(TaskListener.NULL);
        BuildListener dumbListener = new StreamBuildListener(new FileOutputStream(File.createTempFile("dumbListener", "tmp")));
        boolean check = scm.checkout(dumbBuild, dumbLauncher, checkoutDir, dumbListener, File.createTempFile("changelog", "tmp"));
        if (!check) {
            LOGGER.log(Level.SEVERE, "Error trying to load environments and workflows from SCM");
            return;
        }

        readWorkflowsFromDisk(checkoutDir + "/workflows/");

    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Error trying to load environments and workflows from SCM", e);
        return;
    }
}
 
开发者ID:epicforce,项目名称:leroy_jenkins,代码行数:27,代码来源:NewProject.java

示例10: build

import hudson.scm.SCM; //导入依赖的package包/类
@Override
public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull SCMRevision rev) throws IOException, InterruptedException {
	if (scm == null || !(scm instanceof PerforceScm)) {
		return null;
	}
	PerforceScm p4scm = (PerforceScm) scm;

	if (rev != null && !(rev instanceof P4Revision)) {
		return null;
	}
	P4Revision p4rev = (P4Revision) rev;

	try {
		return new P4SCMFileSystem(owner, p4scm, p4rev);
	} catch (Exception e) {
		throw new IOException(e);
	}
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:19,代码来源:P4SCMFileSystem.java

示例11: convertToPerforceScm

import hudson.scm.SCM; //导入依赖的package包/类
/**
 * Helper function for converting an SCM object into a
 * PerforceScm object when appropriate.
 *
 * @param scm the SCM object
 * @return a PerforceScm instance or null
 */
public static PerforceScm convertToPerforceScm(SCM scm) {
	PerforceScm perforceScm = null;
	if (scm instanceof PerforceScm) {
		perforceScm = (PerforceScm) scm;
	} else {
		Jenkins jenkins = Jenkins.getInstance();
		if (jenkins != null) {
			Plugin multiSCMPlugin = jenkins.getPlugin("multiple-scms");
			if (multiSCMPlugin != null) {
				if (scm instanceof MultiSCM) {
					MultiSCM multiSCM = (MultiSCM) scm;
					for (SCM configuredSCM : multiSCM.getConfiguredSCMs()) {
						if (configuredSCM instanceof PerforceScm) {
							perforceScm = (PerforceScm) configuredSCM;
							break;
						}
					}
				}
			}
		}
	}
	return perforceScm;
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:31,代码来源:PerforceScm.java

示例12: createSCM

import hudson.scm.SCM; //导入依赖的package包/类
@Override
protected SCM createSCM() {
	P4Browser browser = PerforceScm.findBrowser(credential);

	if (workspace == null) {
		workspace = getSource().getWorkspace(charset, format);
	}

	// use basic populate options if no class provided
	if (populate == null) {
		populate = new AutoCleanImpl();
	}

	PerforceScm scm = new PerforceScm(credential, workspace, null, populate, browser);

	return scm;
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:18,代码来源:P4Step.java

示例13: matchServer

import hudson.scm.SCM; //导入依赖的package包/类
private boolean matchServer(Job<?, ?> job, String port) {
	//Get all the trigger for this Job
	SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);

	if (item != null) {
		//As soon as we find a match, return
		for (SCM scmTrigger : item.getSCMs()) {
			PerforceScm p4scm = PerforceScm.convertToPerforceScm(scmTrigger);
			if (p4scm != null) {
				String id = p4scm.getCredential();
				P4BaseCredentials credential = ConnectionHelper.findCredential(id);
				if (credential != null
						&& credential.getP4port() != null
						&& port.equals(credential.getP4port())) {
					return true;
				}
			}
		}
	}
	return false;
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:22,代码来源:P4Trigger.java

示例14: testConfigBasic

import hudson.scm.SCM; //导入依赖的package包/类
@Test
public void testConfigBasic() throws Exception {
	FreeStyleProject project = jenkins.createFreeStyleProject();

	String credential = "123";
	Workspace workspace = new StaticWorkspaceImpl("none", false, defaultClient());
	Populate populate = new AutoCleanImpl();
	PerforceScm scm = new PerforceScm(credential, workspace, populate);

	project.setScm(scm);
	SCM testScm = project.getScm();
	assertEquals("org.jenkinsci.plugins.p4.PerforceScm", testScm.getType());

	assertTrue(testScm.supportsPolling());
	assertFalse(testScm.requiresWorkspaceForPolling());

	assertEquals(testScm, project.getScm());
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:19,代码来源:PerforceScmTest.java

示例15: onCheckout

import hudson.scm.SCM; //导入依赖的package包/类
@Override
public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener, File changelogFile,
                       SCMRevisionState pollingBaseline) throws Exception {
    try {
        sendNotifications(build, listener);
    } catch (IOException | InterruptedException e) {
        e.printStackTrace(listener.error("Could not send notifications"));
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:10,代码来源:GiteaNotifier.java


注:本文中的hudson.scm.SCM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。