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 } } } } }
scmRevisionHash = ((AbstractGitSCMSource.SCMRevisionImpl) scmRevision).getHash();
@Override public long lastModified() throws IOException, InterruptedException { return invoke(new FSFunction<Long>() { @Override public Long invoke(Repository repository) throws IOException { try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(commitId); return TimeUnit.SECONDS.toMillis(commit.getCommitTime()); } } }); }
private void round2() throws Exception { sampleRepo.git("checkout", "master"); sampleRepo.write("Jenkinsfile", "// more"); sampleRepo.git("commit", "--all", "--message=master-2"); sampleRepo.git("checkout", "newfeature"); sampleRepo.write("Jenkinsfile", "// more"); sampleRepo.git("commit", "--all", "--message=newfeature-2"); sampleRepo.git("checkout", "release"); sampleRepo.write("Jenkinsfile", "// more"); sampleRepo.git("commit", "--all", "--message=release-2"); sampleRepo.notifyCommit(r); }
/** * {@inheritDoc} */ @Override protected void decorateBuilder(SCMBuilder<?,?> builder) { ((GitSCMBuilder<?>)builder).withCredentials(credentialsId); }
/** * {@inheritDoc} */ @Override protected void decorateContext(SCMSourceContext<?, ?> context) { ((GitSCMSourceContext<?,?>)context).withGitTool(gitTool); }
/** * {@inheritDoc} */ @Override protected void decorateBuilder(SCMBuilder<?,?> builder) { ((GitSCMBuilder<?>) builder).withExtension(extension); } }
@Override public long lastModified() throws IOException, InterruptedException { // TODO a more correct implementation return fs.lastModified(); }
@Override public V invoke(Repository repository, VirtualChannel virtualChannel) throws IOException, InterruptedException { return function.invoke(repository); } });
/** * {@inheritDoc} */ @Override protected void decorateBuilder(SCMBuilder<?, ?> builder) { ((GitSCMBuilder<?>) builder).withGitTool(gitTool); }
/** * {@inheritDoc} */ @Override protected void decorateBuilder(SCMBuilder<?, ?> builder) { ((GitSCMBuilder<?>) builder).withBrowser(browser); }
/** * {@inheritDoc} */ @Override protected void decorateContext(SCMSourceContext<?, ?> context) { ((GitSCMSourceContext<?, ?>) context).withIgnoreOnPushNotifications(true); }
/** * {@inheritDoc} */ @Override protected void decorateContext(SCMSourceContext<?, ?> context) { ((GitSCMSourceContext<?, ?>) context).withRemoteName(remoteName); }
/** * {@inheritDoc} */ @Override protected void decorateBuilder(SCMBuilder<?, ?> builder) { ((GitSCMBuilder<?>) builder).withRemoteName(remoteName); }
@Override public String getDisplayName() { return Messages.GitStep_git(); }
@Override public int hashCode() { return super.hashCode(); // good enough }
@Override public String getDisplayName() { return Messages.GitSCMSource_DisplayName(); }
private void round1() throws Exception { sampleRepo.init(); sampleRepo.write("Jenkinsfile", ""); sampleRepo.git("add", "Jenkinsfile"); sampleRepo.git("commit", "--message=init"); sampleRepo.git("checkout", "-b", "newfeature"); sampleRepo.write("Jenkinsfile", "// newfeature"); sampleRepo.git("commit", "--all", "--message=newfeature"); sampleRepo.git("checkout", "-b", "release", "master"); sampleRepo.write("Jenkinsfile", "// release"); sampleRepo.git("commit", "--all", "--message=release"); }
private void round3() throws Exception { sampleRepo.git("checkout", "master"); sampleRepo.write("Jenkinsfile", "// yet more"); sampleRepo.git("commit", "--all", "--message=master-3"); sampleRepo.git("checkout", "newfeature"); sampleRepo.write("Jenkinsfile", "// yet more"); sampleRepo.git("commit", "--all", "--message=newfeature-3"); sampleRepo.git("checkout", "release"); sampleRepo.write("Jenkinsfile", "// yet more"); sampleRepo.git("commit", "--all", "--message=release-3"); sampleRepo.notifyCommit(r); }