public void run() { for (SCMSource scmSource : ((SCMSourceOwner) project).getSCMSources()) { if (scmSource instanceof GitSCMSource) { GitSCMSource gitSCMSource = (GitSCMSource) scmSource; try { if (new URIish(gitSCMSource.getRemote()).equals(new URIish(gitSCMSource.getRemote()))) { if (!gitSCMSource.isIgnoreOnPushNotifications()) { LOGGER.log(Level.FINE, "Notify scmSourceOwner {0} about changes for {1}", toArray(project.getName(), gitSCMSource.getRemote())); ((SCMSourceOwner) project).onSCMSourceUpdated(scmSource); } else { LOGGER.log(Level.FINE, "Ignore on push notification for scmSourceOwner {0} about changes for {1}", toArray(project.getName(), gitSCMSource.getRemote())); } } } catch (URISyntaxException e) { // nothing to do } } } } }
private void onCreated(SCMSourceOwner item) { for (SCMSource source : item.getSCMSources()) { if (source instanceof GitLabSCMSource) { register((GitLabSCMSource) source, item); } } }
try { for (SCMSourceOwner owner : SCMSourceOwners.all()) { for (SCMSource source : owner.getSCMSources()) { if (source instanceof SubversionSCMSource) { if (id.equals(((SubversionSCMSource) source).getUuid())) { LOGGER.log(Level.INFO, "SCM changes detected relevant to {0}. Notifying update", owner.getFullDisplayName()); owner.onSCMSourceUpdated(source); notified = true;
for (SCMSource source : project.getSCMSources()) { if (!(source instanceof MercurialSCMSource)) { continue; String repository = hgSource.getSource(); if (StringUtils.isBlank(repository)) { LOGGER.log(Level.WARNING, "project {0} is using source control but does not identify a repository", project.getFullName()); continue; LOGGER.log(Level.INFO, "for {0}: {1} vs. {2}", new Object[] {project.getFullName(), url, repository}); if (!looselyMatches(url, repository)) { continue; project.getFullName(), origin }); project.onSCMSourceUpdated(source); projects.add(project);
private boolean hasAccessToCredentialsMetadata(SCMSourceOwner owner){ if (owner == null){ return Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER); } return owner.hasPermission(Item.EXTENDED_READ); }
@Override public void visitSource(@Nonnull String sourceName, @Nonnull SCMSourceObserver observer) throws IOException, InterruptedException { LOGGER.info("visiting " + sourceName + " for context " + observer.getContext().getFullName()); createVisitor(observer).visitProject(sourceName); }
@Override public void writeBody(PrintWriter w) { w.println("Scheduled indexing of " + owner.getFullDisplayName()); } });
private void onDeleted(SCMSourceOwner owner) { for (SCMSource source : owner.getSCMSources()) { if (source instanceof GitLabSCMSource) { unregister((GitLabSCMSource) source, owner); } } }
for (SCMSource source : owner.getSCMSources()) { if (source instanceof GitSCMSource) { GitSCMSource git = (GitSCMSource) source; LOGGER.info("Triggering the indexing of " + owner.getFullDisplayName() + " as a result of event from " + origin); owner.onSCMSourceUpdated(source); result.add(new GitStatus.ResponseContributor() { @Override
if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { return FormValidation.ok();
@Override public void visitSources(@Nonnull SCMSourceObserver observer) throws IOException, InterruptedException { LOGGER.info("visiting sources for context " + observer.getContext().getFullName() + "..."); createVisitor(observer).visitSources(); }
@Override public void parseAssociatedNames(Item item, Collection<GitHubRepositoryName> result) { if (item instanceof SCMSourceOwner) { SCMSourceOwner sourceOwner = (SCMSourceOwner) item; for (SCMSource source : sourceOwner.getSCMSources()) { if (source instanceof GitHubSCMSource) { GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) source; result.add(gitHubSCMSource.getRepoFullName()); } } } } }
if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { return FormValidation.ok();
private String getFullName(GitHubPRDecisionContext context) { GitHubPRTrigger prTrigger = context.getTrigger(); if (nonNull(prTrigger)) { return prTrigger.getJob().getFullName(); } return context.getScmSource().getOwner().getFullName(); }
@Override protected boolean isApplicable(@Nullable Item item) { if (item instanceof SCMSourceOwner) { SCMSourceOwner scmSourceOwner = (SCMSourceOwner) item; for (SCMSource source : scmSourceOwner.getSCMSources()) { if (source instanceof GitHubSCMSource) { GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) source; for (GitHubHandler hubHandler : gitHubSCMSource.getHandlers()) { if (hubHandler instanceof GitHubPRHandler) { return true; } } } } } return false; }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverUrl, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), AuthenticationTokens.matcher(GiteaAuth.class) ); return result; }
@Override protected boolean isApplicable(@Nullable Item item) { if (item instanceof SCMSourceOwner) { SCMSourceOwner scmSourceOwner = (SCMSourceOwner) item; for (SCMSource source : scmSourceOwner.getSCMSources()) { if (source instanceof GitHubSCMSource) { GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) source; for (GitHubHandler hubHandler : gitHubSCMSource.getHandlers()) { if (hubHandler instanceof GitHubBranchHandler) { return true; } } } } } return false; }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverUrl, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), AuthenticationTokens.matcher(GiteaAuth.class) ); return result; }
public static <ITEM extends Item> Predicate<ITEM> withBranchHandler() { return item -> { if (item instanceof SCMSourceOwner) { SCMSourceOwner scmSourceOwner = (SCMSourceOwner) item; for (SCMSource source : scmSourceOwner.getSCMSources()) { if (source instanceof GitHubSCMSource) { GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) source; for (GitHubHandler hubHandler : gitHubSCMSource.getHandlers()) { if (hubHandler instanceof GitHubBranchHandler) { return true; } } } } } return false; }; } //
@Restricted(NoExternalUse.class) public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) { if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) || context != null && !context.hasPermission(Item.EXTENDED_READ)) { return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId); } StandardListBoxModel result = new StandardListBoxModel(); result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS); return result.includeMatchingAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardUsernameCredentials.class, SettingsUtils.gitLabConnectionRequirements(connectionName), GitClient.CREDENTIALS_MATCHER ); }