Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-59415] run context for GitSCMExtension #766

Merged
merged 3 commits into from Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -781,7 +781,7 @@ private PollingResult compareRemoteRevisionWithImpl(Job<?, ?> project, Launcher

// Fetch updates
for (RemoteConfig remoteRepository : getParamExpandedRepos(lastBuild, listener)) {
fetchFrom(git, listener, remoteRepository);
fetchFrom(git, null, listener, remoteRepository);
}

listener.getLogger().println("Polling for changes in");
Expand Down Expand Up @@ -876,12 +876,14 @@ private BuildData fixNull(BuildData bd) {
* Fetch information from a particular remote repository.
*
* @param git git client
* @param run run context if it's running for build
* @param listener build log
* @param remoteRepository remote git repository
* @throws InterruptedException when interrupted
* @throws IOException on input or output error
*/
private void fetchFrom(GitClient git,
@CheckForNull Run<?, ?> run,
TaskListener listener,
RemoteConfig remoteRepository) throws InterruptedException, IOException {

Expand All @@ -897,7 +899,7 @@ private void fetchFrom(GitClient git,

FetchCommand fetch = git.fetch_().from(url, remoteRepository.getFetchRefSpecs());
for (GitSCMExtension extension : extensions) {
extension.decorateFetchCommand(this, git, listener, fetch);
extension.decorateFetchCommand(this, run, git, listener, fetch);
}
fetch.execute();
} catch (GitException ex) {
Expand Down Expand Up @@ -1116,7 +1118,7 @@ private void retrieveChanges(Run build, GitClient git, TaskListener listener) th

for (RemoteConfig remoteRepository : repos) {
try {
fetchFrom(git, listener, remoteRepository);
fetchFrom(git, build, listener, remoteRepository);
} catch (GitException ex) {
/* Allow retry by throwing AbortException instead of
* GitException. See JENKINS-20531. */
Expand Down
Expand Up @@ -266,10 +266,28 @@ public void decorateCloneCommand(GitSCM scm, AbstractBuild<?, ?> build, GitClien
* @throws IOException on input or output error
* @throws InterruptedException when interrupted
* @throws GitException on git error
* @deprecated use {@link #decorateCheckoutCommand(GitSCM, Run, GitClient, TaskListener, CheckoutCommand)}
*/
@Deprecated
public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listener, FetchCommand cmd) throws IOException, InterruptedException, GitException {
}

/**
* Called before a {@link FetchCommand} is executed to allow extensions to alter its behaviour.
* @param scm GitSCM object
* @param run Run when fetch is called for Run. null during Job polling.
* @param git GitClient
* @param listener build log
* @param cmd fetch command to be decorated
* @throws IOException on input or output error
* @throws InterruptedException when interrupted
* @throws GitException on git error
*/
public void decorateFetchCommand(GitSCM scm, @CheckForNull Run<?,?> run, GitClient git, TaskListener listener, FetchCommand cmd)
throws IOException, InterruptedException, GitException {
decorateFetchCommand(scm, git, listener, cmd);
}

/**
* Called before a {@link MergeCommand} is executed to allow extensions to alter its behaviour.
* @param scm GitSCM object
Expand Down