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-65315: SubmoduleOption: resolve env vars in reference path #1556

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package hudson.plugins.git.extensions.impl;

import hudson.EnvVars;
import hudson.Extension;
import hudson.model.Computer;
import hudson.model.Node;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.plugins.git.GitException;
Expand All @@ -9,6 +12,8 @@
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;
import hudson.plugins.git.util.BuildData;
import hudson.plugins.git.util.GitUtils;
import hudson.slaves.NodeProperty;
import java.io.IOException;
import java.util.Objects;
import org.jenkinsci.plugins.gitclient.GitClient;
Expand Down Expand Up @@ -179,11 +184,21 @@ public void onCheckoutCompleted(GitSCM scm, Run<?, ?> build, GitClient git, Task
// This ensures we don't miss changes to submodule paths and allows
// seamless use of bare and non-bare superproject repositories.
git.setupSubmoduleUrls(revToBuild.lastBuild.getRevision(), listener);

Node node = GitUtils.workspaceToNode(git.getWorkTree());
EnvVars env = build.getEnvironment(listener);
Computer comp = node.toComputer();
if (comp != null) {
env.putAll(comp.getEnvironment());
}
for (NodeProperty nodeProperty: node.getNodeProperties()) {
nodeProperty.buildEnvVars(env, listener);
}
SubmoduleUpdateCommand cmd = git.submoduleUpdate()
.recursive(recursiveSubmodules)
.remoteTracking(trackingSubmodules)
.parentCredentials(parentCredentials)
.ref(build.getEnvironment(listener).expand(reference))
.ref(env.expand(reference))
.timeout(timeout)
.shallow(shallow);
if (shallow) {
Expand Down