Skip to content

Commit b3360f6

Browse files
committed
Generic octo using tool cache
1 parent adb6b7c commit b3360f6

File tree

8 files changed

+261
-0
lines changed

8 files changed

+261
-0
lines changed
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
10+
Object.defineProperty(exports, "__esModule", { value: true });
11+
const tasks = require("vsts-task-lib/task");
12+
function run() {
13+
return __awaiter(this, void 0, void 0, function* () {
14+
try {
15+
const octoConnectedServiceName = tasks.getInput("OctoConnectedServiceName", true);
16+
const args = tasks.getInput("args", false);
17+
const command = tasks.getInput("command", true);
18+
const octoEndpointAuthorization = tasks.getEndpointAuthorization(octoConnectedServiceName, false);
19+
const octopusUrl = tasks.getEndpointUrl(octoConnectedServiceName, false);
20+
const apiKey = octoEndpointAuthorization.parameters["apitoken"];
21+
const dotnet = tasks.tool(tasks.which("dotnet", false));
22+
const octo = tasks.which("Octo", true);
23+
dotnet.arg(`${octo}.dll`);
24+
dotnet.arg(command);
25+
dotnet.arg(`--server=${octopusUrl}`);
26+
dotnet.arg(`--apiKey=${apiKey}`);
27+
dotnet.line(args);
28+
const code = yield dotnet.exec();
29+
tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded with code " + code);
30+
}
31+
catch (err) {
32+
tasks.error(err);
33+
tasks.setResult(tasks.TaskResult.Failed, "Failed to execute octo command. " + err.message);
34+
}
35+
});
36+
}
37+
run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as tasks from 'vsts-task-lib/task';
2+
import { ToolRunner } from 'vsts-task-lib/toolrunner';
3+
import path = require('path');
4+
5+
async function run(){
6+
try{
7+
const octoConnectedServiceName = tasks.getInput("OctoConnectedServiceName", true);
8+
const args = tasks.getInput("args", false);
9+
const command = tasks.getInput("command", true);
10+
11+
const octoEndpointAuthorization = tasks.getEndpointAuthorization(octoConnectedServiceName, false);
12+
const octopusUrl = tasks.getEndpointUrl(octoConnectedServiceName, false);
13+
const apiKey = octoEndpointAuthorization.parameters["apitoken"];
14+
15+
const dotnet: ToolRunner =tasks.tool(tasks.which("dotnet", false));
16+
const octo = tasks.which("Octo", true);
17+
18+
dotnet.arg(`${octo}.dll`);
19+
dotnet.arg(command);
20+
dotnet.arg(`--server=${octopusUrl}`);
21+
dotnet.arg(`--apiKey=${apiKey}`);
22+
dotnet.line(args);
23+
24+
const code: number = await dotnet.exec();
25+
26+
tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded with code " + code);
27+
}catch(err){
28+
tasks.error(err);
29+
tasks.setResult(tasks.TaskResult.Failed, "Failed to execute octo command. " + err.message);
30+
}
31+
}
32+
33+
run();

source/VSTSExtensions/OctopusBuildAndReleaseTasks/Tasks/OctoCli/package-lock.json

+108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "octocli",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "octocli.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"vso-node-api": "^6.5.0",
13+
"vsts-task-lib": "^2.4.0"
14+
},
15+
"devDependencies": {
16+
"@types/node": "^6.0.108"
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"id": "25fee290-e578-491b-b1db-dbc3980df1d0",
3+
"name": "OctoCli",
4+
"friendlyName": "Invoke octo cli command",
5+
"description": "Invoke an octo cli command",
6+
"helpMarkDown": "set-by-pack.ps1",
7+
"category": "Package",
8+
"visibility": [
9+
"Build",
10+
"Release"
11+
],
12+
"author": "Octopus Deploy",
13+
"version": {
14+
"Major": 0,
15+
"Minor": 0,
16+
"Patch": 16
17+
},
18+
"minimumAgentVersion": "1.95.0",
19+
"groups": [
20+
{
21+
"name": "advanced",
22+
"displayName": "Advanced Options",
23+
"isExpanded": false
24+
}
25+
],
26+
"inputs": [
27+
{
28+
"name": "OctoConnectedServiceName",
29+
"type": "connectedService:OctopusEndpoint",
30+
"label": "Octopus Deploy Server",
31+
"defaultValue": "",
32+
"required": true,
33+
"helpMarkDown": "Octopus Deploy server connection"
34+
},
35+
{
36+
"name": "command",
37+
"type": "string",
38+
"label": "command",
39+
"defaultValue": "",
40+
"required": true,
41+
"helpMarkDown": "The octo command to execute."
42+
},
43+
{
44+
"name": "args",
45+
"type": "string",
46+
"label": "arguments",
47+
"defaultValue": "",
48+
"required": false,
49+
"helpMarkDown": "The arguments to use for the command."
50+
}
51+
],
52+
"instanceNameFormat": "Invoke an octo cli command",
53+
"execution": {
54+
"Node": {
55+
"target": "octocli.js"
56+
}
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "commonjs"
5+
}
6+
}

0 commit comments

Comments
 (0)