hudson.scm.SCM Java Examples
The following examples show how to use
hudson.scm.SCM.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GiteaWebhookListener.java From gitea-plugin with MIT License | 6 votes |
/** * {@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); } } }
Example #2
Source File: AWSCodePipelineSCM.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 6 votes |
@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()); }
Example #3
Source File: GitLabRequireOrganizationMembershipACL.java From gitlab-oauth-plugin with MIT License | 6 votes |
private String getRepositoryName() { String repositoryName = null; SCM scm = this.project.getScm(); if (scm instanceof GitSCM) { GitSCM git = (GitSCM)scm; List<UserRemoteConfig> userRemoteConfigs = git.getUserRemoteConfigs(); if (!userRemoteConfigs.isEmpty()) { String repoUrl = userRemoteConfigs.get(0).getUrl(); if (repoUrl != null) { GitlabRepositoryName gitlabRepositoryName = GitlabRepositoryName.create(repoUrl); if (gitlabRepositoryName != null) { repositoryName = gitlabRepositoryName.userName + "/" + gitlabRepositoryName.repositoryName; } } } } return repositoryName; }
Example #4
Source File: HistoryAggregatedFlakyTestResultAction.java From flaky-test-handler-plugin with Apache License 2.0 | 6 votes |
/** * Construct a SingleTestFlakyStatsWithRevision object with {@link SingleTestFlakyStats} and * build information. * * @param stats Embedded {@link SingleTestFlakyStats} object * @param build The {@link hudson.model.Run} object to get SCM information from. */ public SingleTestFlakyStatsWithRevision(SingleTestFlakyStats stats, Run build) { this.stats = stats; revision = Integer.toString(build.getNumber()); Job job = build.getParent(); SCMTriggerItem s = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job); if (s != null) { ArrayList<SCM> scms = new ArrayList<>(s.getSCMs()); SCM scm = scms.size() > 0 ? scms.get(0) : null; if (scm != null && "hudson.plugins.git.GitSCM".equalsIgnoreCase(scm.getType())) { GitSCM gitSCM = (GitSCM) scm; BuildData buildData = gitSCM.getBuildData(build); if (buildData != null) { Revision gitRevision = buildData.getLastBuiltRevision(); if (gitRevision != null) { revision = gitRevision.getSha1String(); } } } } }
Example #5
Source File: OpenShiftImageStreams.java From jenkins-plugin with Apache License 2.0 | 5 votes |
@Nonnull @Override protected SCM createSCM() { com.openshift.jenkins.plugins.pipeline.OpenShiftImageStreams scm = new com.openshift.jenkins.plugins.pipeline.OpenShiftImageStreams( name, tag, apiURL, namespace, authToken, verbose); scm.setAuth(auth); return scm; }
Example #6
Source File: RepoInfo.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
public static RepoInfo fromSqsJob(SQSJob sqsJob) { if (sqsJob == null) { return null; } RepoInfo repoInfo = new RepoInfo(); List<SCM> scms = sqsJob.getScmList(); List<String> codeCommitUrls = new ArrayList<>(); List<String> nonCodeCommitUrls = new ArrayList<>(); List<String> branches = new ArrayList<>(); for (SCM scm : scms) { if (scm instanceof GitSCM) {//TODO refactor to visitor GitSCM git = (GitSCM) scm; List<RemoteConfig> repos = git.getRepositories(); for (RemoteConfig repo : repos) { for (URIish urIish : repo.getURIs()) { String url = urIish.toString(); if (StringUtils.isCodeCommitRepo(url)) { codeCommitUrls.add(url); } else { nonCodeCommitUrls.add(url); } } } for (BranchSpec branchSpec : git.getBranches()) { branches.add(branchSpec.getName()); } } } repoInfo.nonCodeCommitUrls = nonCodeCommitUrls; repoInfo.codeCommitUrls = codeCommitUrls; repoInfo.branches = branches; return repoInfo; }
Example #7
Source File: ScmJobEventTriggerMatcher.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
private boolean matchesMultiSCM(final Event event, final SCM scmProvider) { if (!(scmProvider instanceof org.jenkinsci.plugins.multiplescms.MultiSCM)) { return false; } final MultiSCM multiSCM = (MultiSCM) scmProvider; final List<SCM> scms = multiSCM.getConfiguredSCMs(); for (final SCM scm : scms) { if (this.matches(event, scm)) { return true; } } return false; }
Example #8
Source File: ScmJobEventTriggerMatcher.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
private boolean matchesGitSCM(final Event event, final SCM scmProvider) { if (!(scmProvider instanceof GitSCM)) { return false; } final GitSCM git = (GitSCM) scmProvider; final List<RemoteConfig> configs = git.getRepositories(); boolean matched = this.matchesConfigs(event, configs); matched = matched && this.matchBranch(event, git.getBranches()); return matched; }
Example #9
Source File: ScmJobEventTriggerMatcher.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
private boolean matches(final Event event, final SCM scm) { if (event == null || scm == null) { return false; } if (this.isGitScmAvailable() && this.matchesGitSCM(event, scm)) { return true; } else if (this.isMultiScmAvailable() && this.matchesMultiSCM(event, scm)) { return true; } else { return false; } }
Example #10
Source File: AWSCodePipelineSCMTest.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 5 votes |
@Test public void testRoundTripConfiguration() throws Exception { final AWSCodePipelineSCM before = awsCodePipelineSCM; final Project project = jenkinsRule.createFreeStyleProject(); project.setScm(before); jenkinsRule.configRoundtrip(project); final SCM after = project.getScm(); jenkinsRule.assertEqualDataBoundBeans(before, after); }
Example #11
Source File: GiteaNotifier.java From gitea-plugin with MIT License | 5 votes |
@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")); } }
Example #12
Source File: BuildStatusAction.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private boolean hasGitSCM(SCMTriggerItem item) { if (item != null) { for (SCM scm : item.getSCMs()) { if (scm instanceof GitSCM) { return true; } } } return false; }
Example #13
Source File: AbstractWebHookTriggerHandler.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private GitSCM getGitSCM(SCMTriggerItem item) { if (item != null) { for (SCM scm : item.getSCMs()) { if (scm instanceof GitSCM) { return (GitSCM) scm; } } } return null; }
Example #14
Source File: GitLabPipelineStatusNotifier.java From gitlab-branch-source-plugin with MIT License | 5 votes |
@Override public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState pollingBaseline) { LOGGER.log(Level.FINE, String.format("SCMListener: Checkout > %s", build.getFullDisplayName())); sendNotifications(build, listener); }
Example #15
Source File: FolderAuthorizationStrategyManagementLink.java From folder-auth-plugin with MIT License | 5 votes |
@Nonnull @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // used by index.jelly public Set<Permission> getAgentPermissions() { HashSet<PermissionGroup> groups = new HashSet<>(PermissionGroup.getAll()); groups.remove(PermissionGroup.get(Run.class)); groups.remove(PermissionGroup.get(SCM.class)); groups.remove(PermissionGroup.get(View.class)); groups.remove(PermissionGroup.get(Item.class)); groups.remove(PermissionGroup.get(Hudson.class)); groups.remove(PermissionGroup.get(Permission.class)); return getSafePermissions(groups); }
Example #16
Source File: ProjectLabelsProvider.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private GitSCM getGitSCM(SCMTriggerItem item) { if (item != null) { for (SCM scm : item.getSCMs()) { if (scm instanceof GitSCM) { return (GitSCM) scm; } } } return null; }
Example #17
Source File: ProjectBranchesProvider.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private GitSCM getGitSCM(SCMTriggerItem item) { if (item != null) { for (SCM scm : item.getSCMs()) { if (scm instanceof GitSCM) { return (GitSCM) scm; } } } return null; }
Example #18
Source File: SupportedSCMFinder.java From config-driven-pipeline-plugin with MIT License | 5 votes |
public static Collection<? extends SCMDescriptor<?>> getSupportedSCMs() { List<SCMDescriptor<?>> list = new ArrayList<>(); for (SCMDescriptor<?> scmDescriptor : SCM.all()) { // It doesn't really make sense to have the None SCM per the spirit of this plugin. if (!scmDescriptor.getDisplayName().equals("None")) { list.add(scmDescriptor); } } return list; }
Example #19
Source File: MultiScmAdapter.java From bitbucket-build-status-notifier-plugin with MIT License | 5 votes |
public Map<String, URIish> getCommitRepoMap() throws Exception { HashMap<String, URIish> commitRepoMap = new HashMap<String, URIish>(); for (SCM scm : multiScm.getConfiguredSCMs()) { if (scm instanceof GitSCM) { commitRepoMap.putAll(new GitScmAdapter((GitSCM) scm, this.build).getCommitRepoMap()); } else if (scm instanceof MercurialSCM) { commitRepoMap.putAll(new MercurialScmAdapter((MercurialSCM) scm, this.build).getCommitRepoMap()); } } return commitRepoMap; }
Example #20
Source File: GitHubSCMSource.java From github-integration-plugin with MIT License | 4 votes |
@Nonnull @Override public SCM build(@Nonnull SCMHead scmHead, SCMRevision scmRevision) { return scmFactory.createScm(this, scmHead, scmRevision); }
Example #21
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 4 votes |
@Override public SCM build(SCMHead head, SCMRevision revision) { return new GitHubSCMBuilder(this, head, revision).withTraits(traits).build(); }
Example #22
Source File: PullRequestGHEventSubscriber.java From github-branch-source-plugin with MIT License | 4 votes |
@Override public boolean isMatch(@NonNull SCM scm) { return false; }
Example #23
Source File: PushGHEventSubscriber.java From github-branch-source-plugin with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public boolean isMatch(@NonNull SCM scm) { return false; }
Example #24
Source File: SSHCheckoutTrait.java From github-branch-source-plugin with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public Class<? extends SCM> getScmClass() { return GitSCM.class; }
Example #25
Source File: FakeChangeLogSCM.java From jenkins-test-harness with MIT License | 4 votes |
@Override public SCMDescriptor<?> getDescriptor() { return new SCMDescriptor<SCM>(null) {}; }
Example #26
Source File: GitHubBuildStatusNotification.java From github-branch-source-plugin with MIT License | 4 votes |
@Override public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState pollingBaseline) throws Exception { createBuildCommitStatus(build, listener); }
Example #27
Source File: GitHubSCMFileSystem.java From github-branch-source-plugin with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public boolean supports(SCM source) { // TODO implement a GitHubSCM so we can work for those return false; }
Example #28
Source File: GitHubSCMFileSystem.java From github-branch-source-plugin with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull SCMRevision rev) { return null; }
Example #29
Source File: ProjectFixture.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 4 votes |
public ProjectFixture setScm(SCM scm) { this.scm = scm; return this; }
Example #30
Source File: GitHubSCMFileSystemBuilder.java From github-integration-plugin with MIT License | 4 votes |
@Override public boolean supports(SCM source) { return false; }