Skip to content

Commit 2d94f04

Browse files
Add signal handling to the BashV3 task
1 parent 478b013 commit 2d94f04

38 files changed

+816
-568
lines changed

Tasks/BashV3/_buildConfigs/Node20/package-lock.json

+220-108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/BashV3/_buildConfigs/Node20/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@types/mocha": "^9.1.1",
2222
"@types/node": "^20.3.1",
23-
"azure-pipelines-task-lib": "^4.16.0",
23+
"azure-pipelines-task-lib": "^4.17.3",
2424
"azure-pipelines-tasks-utility-common": "^3.230.0",
2525
"uuid": "^3.0.1"
2626
},

Tasks/BashV3/bash.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,10 @@ async function run() {
184184
ignoreReturnCode: true
185185
};
186186

187-
process.on("SIGINT", () => {
188-
tl.debug('Started cancellation of executing script');
189-
bash.killChildProcess();
187+
['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGTERM', 'EXIT'].forEach((signal) => {
188+
process.on(signal, () => {
189+
bash.killChildProcess(signal as NodeJS.Signals);
190+
});
190191
});
191192

192193
// Listen for stderr.

Tasks/BashV3/package-lock.json

+48-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/BashV3/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@types/mocha": "^9.1.1",
2222
"@types/node": "^16.18.105",
23-
"azure-pipelines-task-lib": "^4.16.0",
23+
"azure-pipelines-task-lib": "^4.17.3",
2424
"azure-pipelines-tasks-utility-common": "^3.230.0",
2525
"uuid": "^3.0.1"
2626
},

Tasks/BashV3/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 3,
20-
"Minor": 246,
20+
"Minor": 250,
2121
"Patch": 0
2222
},
2323
"releaseNotes": "Script task consistency. Added support for multiple lines and added support for Windows.",

Tasks/BashV3/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 3,
20-
"Minor": 246,
20+
"Minor": 250,
2121
"Patch": 0
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",

Tasks/CmdLineV2/_buildConfigs/Node20/package-lock.json

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/CmdLineV2/_buildConfigs/Node20/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@types/mocha": "^8.0.3",
2121
"@types/node": "^20.3.1",
2222
"@types/uuid": "^8.3.0",
23-
"azure-pipelines-task-lib": "^4.15.0",
23+
"azure-pipelines-task-lib": "^4.17.3",
2424
"uuid": "^8.3.0"
2525
},
2626
"devDependencies": {

Tasks/CmdLineV2/cmdline.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function run() {
1414
let workingDirectory = tl.getPathInput('workingDirectory', /*required*/ true, /*check*/ true);
1515

1616
if (fs.existsSync(script)) {
17-
script = `exec ${script}`;
17+
script = `exec bash ${script}`;
1818
}
1919

2020
// Write the script to disk.
@@ -58,9 +58,10 @@ async function run() {
5858
});
5959
}
6060

61-
process.on("SIGINT", () => {
62-
tl.debug('Started cancellation of executing script');
63-
bash.killChildProcess();
61+
['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGTERM', 'EXIT'].forEach((signal) => {
62+
process.on(signal, () => {
63+
bash.killChildProcess(signal as NodeJS.Signals);
64+
});
6465
});
6566

6667
// Run bash.

Tasks/CmdLineV2/package-lock.json

+51-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/CmdLineV2/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@types/mocha": "^8.0.3",
2121
"@types/node": "^16.11.39",
2222
"@types/uuid": "^8.3.0",
23-
"azure-pipelines-task-lib": "^4.15.0",
23+
"azure-pipelines-task-lib": "^4.17.3",
2424
"uuid": "^8.3.0"
2525
},
2626
"devDependencies": {

Tasks/CmdLineV2/task.json

+84-84
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
11
{
2-
"id": "D9BAFED4-0B18-4F58-968D-86655B4D2CE9",
3-
"name": "CmdLine",
4-
"friendlyName": "Command line",
5-
"description": "Run a command line script using Bash on Linux and macOS and cmd.exe on Windows",
6-
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line",
7-
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?LinkID=613735)",
8-
"category": "Utility",
9-
"visibility": [
10-
"Build",
11-
"Release"
12-
],
13-
"runsOn": [
14-
"Agent",
15-
"DeploymentGroup"
16-
],
17-
"author": "Microsoft Corporation",
18-
"version": {
19-
"Major": 2,
20-
"Minor": 246,
21-
"Patch": 0
2+
"id": "D9BAFED4-0B18-4F58-968D-86655B4D2CE9",
3+
"name": "CmdLine",
4+
"friendlyName": "Command line",
5+
"description": "Run a command line script using Bash on Linux and macOS and cmd.exe on Windows",
6+
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line",
7+
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?LinkID=613735)",
8+
"category": "Utility",
9+
"visibility": [
10+
"Build",
11+
"Release"
12+
],
13+
"runsOn": [
14+
"Agent",
15+
"DeploymentGroup"
16+
],
17+
"author": "Microsoft Corporation",
18+
"version": {
19+
"Major": 2,
20+
"Minor": 250,
21+
"Patch": 0
22+
},
23+
"releaseNotes": "Script task consistency. Added support for multiple lines.",
24+
"showEnvironmentVariables": true,
25+
"groups": [
26+
{
27+
"name": "advanced",
28+
"displayName": "Advanced",
29+
"isExpanded": false
30+
}
31+
],
32+
"inputs": [
33+
{
34+
"name": "script",
35+
"type": "multiLine",
36+
"label": "Script",
37+
"required": true,
38+
"defaultValue": "echo Write your commands here\n\necho Hello world\n",
39+
"properties": {
40+
"resizable": "true",
41+
"rows": "10",
42+
"maxLength": "5000"
43+
},
44+
"helpMarkDown": ""
45+
},
46+
{
47+
"name": "workingDirectory",
48+
"type": "filePath",
49+
"label": "Working Directory",
50+
"defaultValue": "",
51+
"required": false,
52+
"groupName": "advanced"
53+
},
54+
{
55+
"name": "failOnStderr",
56+
"type": "boolean",
57+
"label": "Fail on Standard Error",
58+
"defaultValue": "false",
59+
"required": false,
60+
"helpMarkDown": "If this is true, this task will fail if any errors are written to the StandardError stream.",
61+
"groupName": "advanced"
62+
}
63+
],
64+
"instanceNameFormat": "Command Line Script",
65+
"execution": {
66+
"PowerShell3": {
67+
"target": "cmdline.ps1",
68+
"platforms": [
69+
"windows"
70+
]
2271
},
23-
"releaseNotes": "Script task consistency. Added support for multiple lines.",
24-
"showEnvironmentVariables": true,
25-
"groups": [
26-
{
27-
"name": "advanced",
28-
"displayName": "Advanced",
29-
"isExpanded": false
30-
}
31-
],
32-
"inputs": [
33-
{
34-
"name": "script",
35-
"type": "multiLine",
36-
"label": "Script",
37-
"required": true,
38-
"defaultValue": "echo Write your commands here\n\necho Hello world\n",
39-
"properties": {
40-
"resizable": "true",
41-
"rows": "10",
42-
"maxLength": "5000"
43-
},
44-
"helpMarkDown": ""
45-
},
46-
{
47-
"name": "workingDirectory",
48-
"type": "filePath",
49-
"label": "Working Directory",
50-
"defaultValue": "",
51-
"required": false,
52-
"groupName": "advanced"
53-
},
54-
{
55-
"name": "failOnStderr",
56-
"type": "boolean",
57-
"label": "Fail on Standard Error",
58-
"defaultValue": "false",
59-
"required": false,
60-
"helpMarkDown": "If this is true, this task will fail if any errors are written to the StandardError stream.",
61-
"groupName": "advanced"
62-
}
63-
],
64-
"instanceNameFormat": "Command Line Script",
65-
"execution": {
66-
"PowerShell3": {
67-
"target": "cmdline.ps1",
68-
"platforms": [
69-
"windows"
70-
]
71-
},
72-
"Node10": {
73-
"target": "cmdline.js",
74-
"argumentFormat": ""
75-
},
76-
"Node16": {
77-
"target": "cmdline.js",
78-
"argumentFormat": ""
79-
}
72+
"Node10": {
73+
"target": "cmdline.js",
74+
"argumentFormat": ""
8075
},
81-
"messages": {
82-
"GeneratingScript": "Generating script.",
83-
"JS_ExitCode": "Bash exited with code '%s'.",
84-
"JS_Stderr": "Bash wrote one or more lines to the standard error stream.",
85-
"PS_ExitCode": "Cmd.exe exited with code '{0}'.",
86-
"PS_UnableToDetermineExitCode": "Unexpected exception. Unable to determine the exit code from cmd.exe.",
87-
"ScriptContents": "Script contents:"
76+
"Node16": {
77+
"target": "cmdline.js",
78+
"argumentFormat": ""
8879
}
80+
},
81+
"messages": {
82+
"GeneratingScript": "Generating script.",
83+
"JS_ExitCode": "Bash exited with code '%s'.",
84+
"JS_Stderr": "Bash wrote one or more lines to the standard error stream.",
85+
"PS_ExitCode": "Cmd.exe exited with code '{0}'.",
86+
"PS_UnableToDetermineExitCode": "Unexpected exception. Unable to determine the exit code from cmd.exe.",
87+
"ScriptContents": "Script contents:"
88+
}
8989
}

Tasks/CmdLineV2/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 2,
20-
"Minor": 246,
20+
"Minor": 250,
2121
"Patch": 0
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",

_generated/BashV3.versionmap.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|3.246.0
2-
Node20-225|3.246.1
1+
Default|3.250.0
2+
Node20-225|3.250.1

_generated/BashV3/bash.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,10 @@ async function run() {
184184
ignoreReturnCode: true
185185
};
186186

187-
process.on("SIGINT", () => {
188-
tl.debug('Started cancellation of executing script');
189-
bash.killChildProcess();
187+
['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGTERM', 'EXIT'].forEach((signal) => {
188+
process.on(signal, () => {
189+
bash.killChildProcess(signal as NodeJS.Signals);
190+
});
190191
});
191192

192193
// Listen for stderr.

0 commit comments

Comments
 (0)