@@ -204,18 +204,6 @@ func (executor *Executor) PopulateCloneAndWorkingDirEnvironmentVariables(environ
204
204
_ , hasCloneDir := result ["CIRRUS_CLONE_DIR" ]
205
205
_ , hasWorkingDir := result ["CIRRUS_WORKING_DIR" ]
206
206
207
- // Use directory created by the persistent worker if CIRRUS_WORKING_DIR
208
- // was not overridden in the task specification by the user
209
- if executor .preCreatedWorkingDir != "" {
210
- result ["CIRRUS_CLONE_DIR" ] = executor .preCreatedWorkingDir
211
- hasCloneDir = true
212
- // Need to override working dir too
213
- if hasWorkingDir && ! strings .Contains (result ["CIRRUS_WORKING_DIR" ], "CIRRUS_CLONE_DIR" ) {
214
- // If working dir doesn't depend on clone dir then we can default clone dir to the one provided by user
215
- result ["CIRRUS_WORKING_DIR" ] = "$CIRRUS_CLONE_DIR"
216
- }
217
- }
218
-
219
207
if hasCloneDir && ! hasWorkingDir {
220
208
// Only clone was overridden. Make sure $CIRRUS_WORKING_DIR is set
221
209
result ["CIRRUS_WORKING_DIR" ] = "$CIRRUS_CLONE_DIR"
@@ -225,6 +213,7 @@ func (executor *Executor) PopulateCloneAndWorkingDirEnvironmentVariables(environ
225
213
if ! strings .Contains (result ["CIRRUS_WORKING_DIR" ], "CIRRUS_CLONE_DIR" ) {
226
214
// If working dir doesn't depend on clone dir then we can default clone dir to the one provided by user
227
215
result ["CIRRUS_CLONE_DIR" ] = "$CIRRUS_WORKING_DIR"
216
+ hasCloneDir = true
228
217
}
229
218
}
230
219
@@ -233,6 +222,11 @@ func (executor *Executor) PopulateCloneAndWorkingDirEnvironmentVariables(environ
233
222
result ["CIRRUS_WORKING_DIR" ] = "$CIRRUS_CLONE_DIR"
234
223
}
235
224
225
+ if ! hasCloneDir && executor .preCreatedWorkingDir != "" {
226
+ // none of the dirs are explicitly set. Make sure they'll be the same
227
+ result ["CIRRUS_CLONE_DIR" ] = executor .preCreatedWorkingDir
228
+ }
229
+
236
230
if _ , ok := result ["CIRRUS_CLONE_DIR" ]; ! ok {
237
231
defaultTempDirPath := filepath .Join (os .TempDir (), "cirrus-ci-build" )
238
232
if _ , err := os .Stat (defaultTempDirPath ); os .IsNotExist (err ) {
0 commit comments