jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-58367] cwd set by exws set is replaced by withEnv and withCredentials steps

Aperta
#490 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
component:external-workspace-manager-plugin component:workflow-basic-steps-plugin imported-jira-issue priority:major resolution:unresolved
Lingua principale
Java
Stelle
73
Fork
129
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi, 

I am experiencing an unexpected change of the current working directory when withEnv or withCredentials steps are used.

dir step is a viable workaround, but I am wondering if there is a more straightforward explanation and solution.

Thank you!

def extWorkspace = exwsAllocate diskPoolId: 'workspace-pool', strategy: fastestWriteSpeed()

stage('init') {

  node('brenode') {

    println pwd() //prints local workspace (${JENKINS_HOME}/workspace/${JOB_NAME})

    exws (extWorkspace) {

      println pwd() //prints external workspace ${physical_path}/${JOB_NAME}/${BUILD_NUMBER}

      withEnv(["1=1"])

{          println pwd() //prints again local workspace!       }

    }

  }

}

 

---
Originally reported by claudiuavat1, imported from: cwd set by exws set is replaced by withEnv and withCredentials steps


  • assignee: alexsomai
  • status: Open
  • priority: Major
  • component(s): external-workspace-manager-plugin, workflow-basic-steps-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 20251215-220547

Raw content of original issue

Hi, 

I am experiencing an unexpected change of the current working directory when withEnv or withCredentials steps are used.

dir step is a viable workaround, but I am wondering if there is a more straightforward explanation and solution.

Thank you!

def extWorkspace = exwsAllocate diskPoolId: 'workspace-pool', strategy: fastestWriteSpeed()

stage('init') {
  node('brenode') {
    println pwd() //prints local workspace (${JENKINS_HOME}/workspace/${JOB_NAME})
    exws (extWorkspace) {
      println pwd() //prints external workspace ${physical_path}/${JOB_NAME}/${BUILD_NUMBER}
      withEnv(["1=1"])

{          println pwd() //prints again local workspace!       }

    }
  }
}

 

environment

```
JENKINS_VERSION 2.176.1

external-workspace-manager 1.1.2

workflow-basic-steps 2.18
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by reproducing the pipeline using exws, withEnv, and withCredentials, comparing pwd() before and inside each step. Trace the external-workspace-manager-plugin and workflow-basic-steps-plugin entry points involved in workspace context handling; done means the external workspace remains the current directory when environment or credential steps run.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.