Skip to content

Commit a48fad0

Browse files
MCLOUD-14015: Docker cp command & git file permission fixes for local+jenkins
1 parent 34564c0 commit a48fad0

File tree

3 files changed

+25
-40
lines changed

3 files changed

+25
-40
lines changed

tests/functional/Codeception/Docker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function runDockerComposeCommand(string $command): bool
108108
public function resetFilesOwner(): bool
109109
{
110110
return $this->runDockerComposeCommand(
111-
'run build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"'
111+
'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"'
112112
);
113113
}
114114

tests/functional/Robo/Tasks/CopyFromDocker.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,19 @@ public function destination(string $destination): self
7777
/**
7878
* @inheritdoc
7979
*/
80-
public function getCommand(): string
81-
{
82-
// Log the values before using them
83-
error_log('Container for cp: ' . $this->container);
84-
error_log('Source: ' . $this->source);
85-
error_log('Destination: ' . $this->destination);
86-
$check_ps_command = sprintf('docker-compose ps -q %s', $this->container);
87-
error_log('ps command: ' . $check_ps_command);
88-
return sprintf(
89-
'(docker cp %s:%s %s) || (docker-compose cp %s:%s %s)',
90-
$check_ps_command,
91-
$this->source,
92-
$this->destination,
93-
$this->container,
94-
$this->source,
95-
$this->destination
96-
);
97-
98-
99-
100-
}
80+
public function getCommand(): string
81+
{
82+
return sprintf(
83+
'(docker-compose cp %s:%s %s) || (docker cp $(docker-compose ps -q %s):%s %s)',
84+
$this->container,
85+
$this->source,
86+
$this->destination,
87+
$this->container,
88+
$this->source,
89+
$this->destination
90+
);
91+
}
92+
10193
/**
10294
* @inheritdoc
10395
*/

tests/functional/Robo/Tasks/CopyToDocker.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,17 @@ public function destination(string $destination): self
7878
* @inheritdoc
7979
*/
8080
public function getCommand(): string
81-
{
82-
// Log the values before using them
83-
error_log('Container for cp: ' . $this->container);
84-
error_log('Source: ' . $this->source);
85-
error_log('Destination: ' . $this->destination);
86-
$check_ps_command = sprintf('docker-compose ps -q %s', $this->container);
87-
error_log('ps command: ' . $check_ps_command);
88-
return sprintf(
89-
'(docker cp %s:%s %s) || (docker-compose cp %s:%s %s)',
90-
$check_ps_command,
91-
$this->source,
92-
$this->destination,
93-
$this->container,
94-
$this->source,
95-
$this->destination
96-
);
97-
98-
}
81+
{
82+
return sprintf(
83+
'(docker cp %s %s:%s) || (docker-compose cp %s %s:%s)',
84+
$this->source,
85+
$this->container,
86+
$this->destination,
87+
$this->source,
88+
$this->container,
89+
$this->destination
90+
);
91+
}
9992

10093
/**
10194
* @inheritdoc

0 commit comments

Comments
 (0)