Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,9 @@ export class Job {

if (serviceEntrypoint?.length ?? 0 > 1) {
serviceEntrypoint?.slice(1).forEach((e) => {
dockerCmd += `"${e}" `;
dockerCmd += `'${e
.replace(/'/g, "'\"'\"'") // replaces `'` with `'"'"'`
}' `;
});
}
(service.command ?? []).forEach((e) => dockerCmd += `"${e.replace(/\$/g, "\\$")}" `);
Expand Down
17 changes: 17 additions & 0 deletions tests/test-cases/services/.gitlab-ci-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
job1:
services:
- name: nginx:1.27.4-alpine-slim
entrypoint:
- "sh"
- "-c"
- |
cat > /usr/share/nginx/html/index.html <<EOF
should support single quote [']
should support double quote ["]
should support variable expansion [$NGINX_VERSION]
EOF
/docker-entrypoint.sh nginx -g 'daemon off;'
image: busybox
script:
- wget -qO- nginx
16 changes: 16 additions & 0 deletions tests/test-cases/services/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,19 @@ test.concurrent("services <no-tmp>", async () => {
];
expect(writeStreams.stdoutLines).toEqual(expect.arrayContaining(expected));
});

test("services <no-tmp>", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/services",
file: ".gitlab-ci-2.yml",
noColor: true,
}, writeStreams);

const filteredStdout = writeStreams.stdoutLines.filter(f => f.startsWith("job1 >")).join("\n");
expect(filteredStdout).toEqual(`
job1 > should support single quote [']
job1 > should support double quote ["]
job1 > should support variable expansion [1.27.4]
`.trim());
});
Loading