public void setBuildChooser(BuildChooser buildChooser) throws IOException { if (buildChooser.getClass()==DefaultBuildChooser.class) { getExtensions().remove(BuildChooserSetting.class); } else { getExtensions().replace(new BuildChooserSetting(buildChooser)); } }
/** * {@inheritDoc} */ @Override public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listener, FetchCommand cmd) throws IOException, InterruptedException, GitException { listener.getLogger().println("Cleaning workspace"); git.clean(); // TODO: revisit how to hand off to SubmoduleOption for (GitSCMExtension ext : scm.getExtensions()) { ext.onClean(scm, git); } }
/** * {@inheritDoc} */ @Override public void onCheckoutCompleted(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener) throws IOException, InterruptedException, GitException { listener.getLogger().println("Cleaning workspace"); git.clean(); // TODO: revisit how to hand off to SubmoduleOption for (GitSCMExtension ext : scm.getExtensions()) { ext.onClean(scm, git); } }
private boolean requiresWorkspaceForPolling(EnvVars environment) { for (GitSCMExtension ext : getExtensions()) { if (ext.requiresWorkspaceForPolling()) return true; } return getSingleBranch(environment) == null; }
private boolean isShallow(final GitSCM git) { CloneOption option = git.getExtensions().get(CloneOption.class); if (option != null) { return option.isShallow(); } return false; }
@Override public ChangeLogParser createChangeLogParser() { return new GitChangeLogParser(getExtensions().get(AuthorInChangelog.class)!=null); }
public BuildChooser getBuildChooser() { BuildChooser bc; BuildChooserSetting bcs = getExtensions().get(BuildChooserSetting.class); if (bcs!=null) bc = bcs.getBuildChooser(); else bc = new DefaultBuildChooser(); bc.gitSCM = this; return bc; }
@Nonnull @Override public SCM build(@Nonnull SCMHead head, @CheckForNull SCMRevision revision) { GitSCM scm; if (head instanceof GitLabSCMHead) { scm = ((GitLabSCMHead) head).createSCM(this); if (revision instanceof SCMRevisionImpl) { scm.getExtensions().add(new BuildChooserSetting(new SpecificRevisionBuildChooser((SCMRevisionImpl) revision))); } } else { scm = (GitSCM) super.build(head, revision); scm.setBrowser(getBrowser()); } return scm; }
private void checkout(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision rev) throws InterruptedException, IOException, GitException { CheckoutCommand checkoutCommand = git.checkout().ref(rev.getSha1String()); for (GitSCMExtension ext : scm.getExtensions()) { ext.decorateCheckoutCommand(scm, build, git, listener, checkoutCommand); } checkoutCommand.execute(); } }
private void checkout(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision rev) throws InterruptedException, IOException, GitException { CheckoutCommand checkoutCommand = git.checkout().ref(rev.getSha1String()); for (GitSCMExtension ext : scm.getExtensions()) { ext.decorateCheckoutCommand(scm, build, git, listener, checkoutCommand); } checkoutCommand.execute(); } }
LocalBranch lb = getExtensions().get(LocalBranch.class); if (lb != null) {
@Override public GitSCM createScm(GitHubSCMSource scmSource, SCMHead scmHead, SCMRevision scmRevision) { return new GitSCM( gitSCM.getUserRemoteConfigs(), gitSCM.getBranches(), gitSCM.isDoGenerateSubmoduleConfigurations(), gitSCM.getSubmoduleCfg(), gitSCM.getBrowser(), gitSCM.getGitTool(), gitSCM.getExtensions() ); }
List<String> revShow; if (buildData != null && buildData.lastBuild != null) { if (getExtensions().get(PathRestriction.class) != null) { revShow = git.showRevision(buildData.lastBuild.revision.getSha1(), r.getSha1()); } else { for (String line : revShow) { if (line.startsWith("commit ") && idx!=0) { GitChangeSet change = new GitChangeSet(revShow.subList(start,idx), getExtensions().get(AuthorInChangelog.class)!=null);
if(scm.getExtensions().get(RelativeTargetDirectory.class) != null) { relativeTargetDirectory = scm.getExtensions().get(RelativeTargetDirectory.class).getRelativeTargetDir();
git.setCommitter("Jenkins", "nobody@nowhere"); MergeCommand cmd = git.merge().setRevisionToMerge(baseObjectId); for (GitSCMExtension ext : scm.getExtensions()) {
if (scm instanceof GitSCM) { GitSCM git = (GitSCM) scm; if (git.getExtensions().get(IgnoreNotifyCommit.class) != null) { return false;
if (scm instanceof GitSCM) { GitSCM git = (GitSCM) scm; if (git.getExtensions().get(IgnoreNotifyCommit.class) != null) { return false;
@Override public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev) throws IOException, InterruptedException, GitException { listener.getLogger().println("Merging " + targetBranch.getName() + " commit " + targetBranch.getRevision().getHash() + " into merge-request head commit " + rev.getSha1String()); checkout(scm, build, git, listener, rev); try { git.setAuthor("Jenkins", /* could parse out of JenkinsLocationConfiguration.get().getAdminAddress() but seems overkill */"nobody@nowhere"); git.setCommitter("Jenkins", "nobody@nowhere"); MergeCommand cmd = git.merge().setRevisionToMerge(ObjectId.fromString(targetBranch.getRevision().getHash())); for (GitSCMExtension ext : scm.getExtensions()) { // By default we do a regular merge, allowing it to fast-forward. ext.decorateMergeCommand(scm, build, git, listener, cmd); } cmd.execute(); } catch (GitException e) { // Try to revert merge conflict markers. checkout(scm, build, git, listener, rev); throw e; } build.addAction(new MergeRecord(targetBranch.getRefSpec().destinationRef(targetBranch.getName()), targetBranch.getRevision().getHash())); // does not seem to be used, but just in case ObjectId mergeRev = git.revParse(Constants.HEAD); listener.getLogger().println("Merge succeeded, producing " + mergeRev.name()); return new Revision(mergeRev, rev.getBranches()); // note that this ensures Build.revision != Build.marked }
for (GitSCMExtension ext : scm.getExtensions()) ext.decorateCheckoutCommand(scm, build, git, listener, checkoutCommand); checkoutCommand.execute(); for (GitSCMExtension ext : scm.getExtensions()) ext.decorateMergeCommand(scm, build, git, listener, cmd); cmd.execute(); for (GitSCMExtension ext : scm.getExtensions()) ext.decorateCheckoutCommand(scm, build, git, listener, checkoutCommand); checkoutCommand.execute();
try (Writer out = new OutputStreamWriter(changelogFile.write(),"UTF-8")) { boolean exclusion = false; ChangelogToBranch changelogToBranch = getExtensions().get(ChangelogToBranch.class); if (changelogToBranch != null) { listener.getLogger().println("Using 'Changelog to branch' strategy.");