mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
fix regression and add trace in clone for local backend (#2241)
regression of #2017 close #2211
This commit is contained in:
parent
a58e3b9e06
commit
0c282e86e8
1 changed files with 15 additions and 6 deletions
|
@ -86,6 +86,8 @@ func (e *local) execClone(ctx context.Context, step *types.Step, state *workflow
|
||||||
|
|
||||||
// Prepare command
|
// Prepare command
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
|
if rmCmd != "" {
|
||||||
|
// if we have a netrc injected we have to make sure it's deleted in any case after clone was attempted
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
pwsh, err := exec.LookPath("powershell.exe")
|
pwsh, err := exec.LookPath("powershell.exe")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -93,7 +95,11 @@ func (e *local) execClone(ctx context.Context, step *types.Step, state *workflow
|
||||||
}
|
}
|
||||||
cmd = exec.CommandContext(ctx, pwsh, "-Command", fmt.Sprintf("%s ; $code=$? ; %s ; if (!$code) {[Environment]::Exit(1)}", state.pluginGitBinary, rmCmd))
|
cmd = exec.CommandContext(ctx, pwsh, "-Command", fmt.Sprintf("%s ; $code=$? ; %s ; if (!$code) {[Environment]::Exit(1)}", state.pluginGitBinary, rmCmd))
|
||||||
} else {
|
} else {
|
||||||
cmd = exec.CommandContext(ctx, "/bin/sh", "-c", fmt.Sprintf("%s ; $code=$? ; %s ; exit $code", state.pluginGitBinary, rmCmd))
|
cmd = exec.CommandContext(ctx, "/bin/sh", "-c", fmt.Sprintf("%s ; export code=$? ; %s ; exit $code", state.pluginGitBinary, rmCmd))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if we have NO netrc, we can just exec the clone directly
|
||||||
|
cmd = exec.CommandContext(ctx, state.pluginGitBinary)
|
||||||
}
|
}
|
||||||
cmd.Env = env
|
cmd.Env = env
|
||||||
cmd.Dir = state.workspaceDir
|
cmd.Dir = state.workspaceDir
|
||||||
|
@ -110,6 +116,7 @@ func (e *local) execClone(ctx context.Context, step *types.Step, state *workflow
|
||||||
// writeNetRC write a netrc file into the home dir of a given workflow state
|
// writeNetRC write a netrc file into the home dir of a given workflow state
|
||||||
func writeNetRC(step *types.Step, state *workflowState) (string, error) {
|
func writeNetRC(step *types.Step, state *workflowState) (string, error) {
|
||||||
if step.Environment["CI_NETRC_MACHINE"] == "" {
|
if step.Environment["CI_NETRC_MACHINE"] == "" {
|
||||||
|
log.Trace().Msg("no netrc to write")
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +127,7 @@ func writeNetRC(step *types.Step, state *workflowState) (string, error) {
|
||||||
rmCmd = fmt.Sprintf("del \"%s\"", file)
|
rmCmd = fmt.Sprintf("del \"%s\"", file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Trace().Msgf("try to write netrc to '%s'", file)
|
||||||
return rmCmd, os.WriteFile(file, []byte(fmt.Sprintf(
|
return rmCmd, os.WriteFile(file, []byte(fmt.Sprintf(
|
||||||
netrcFile,
|
netrcFile,
|
||||||
step.Environment["CI_NETRC_MACHINE"],
|
step.Environment["CI_NETRC_MACHINE"],
|
||||||
|
@ -177,6 +185,7 @@ func downloadLatestGitPluginBinary(dest string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// download successful
|
// download successful
|
||||||
|
log.Trace().Msgf("download of 'plugin-git' to '%s' successful", dest)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue