diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/de-de/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/de-de/resources.resjson
deleted file mode 100644
index 3b4017a10ba7..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/de-de/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "er für Kubectl-Tool",
- "loc.helpMarkDown": "[Weitere Informationen](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "Kubectl auf Agentcomputer installieren",
- "loc.instanceNameFormat": "Kubectl $(kubectlVersion) installieren",
- "loc.input.label.kubectlVersion": "Kubectl-Versionsangabe",
- "loc.input.help.kubectlVersion": "Geben Sie die zu installierende Kubectl-Version an.",
- "loc.messages.NotAValidSemverVersion": "Version nicht im richtigen Format angegeben. Beispiel: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "loc.messages.VerifyKubectlInstallation": "Die kubectl-Installation wird überprüft..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/en-US/resources.resjson
deleted file mode 100644
index ca61e2cf30cb..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/en-US/resources.resjson
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "loc.friendlyName": "Container Build Task",
- "loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
- "loc.description": "Build Task",
- "loc.instanceNameFormat": "Container Build Task",
- "loc.input.label.buildctlVersion": "Buildctl Version Spec",
- "loc.input.help.buildctlVersion": "Specify the version of Buildctl to install",
- "loc.input.label.Dockerfile": "Dockerfile",
- "loc.input.help.Dockerfile": "Path to the Dockerfile.",
- "loc.input.label.localContext": "Build context",
- "loc.input.help.localContext": "Path to the Build context.",
- "loc.messages.NotAValidSemverVersion": "Version not specified in correct format. E.g: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "loc.messages.VerifyBuildctlInstallation": "Verifying Buildctl installation...",
- "loc.messages.BuildctlLatestNotKnown": "Cannot get the latest Buildctl info from %s. Error %s. Using default Buildctl version %s.",
- "loc.messages.BuildctlDownloadFailed": "Failed to download Buildctl from location %s. Error %s",
- "loc.messages.BuildctlNotFoundInFolder": "Buildctl executable not found in path %s"
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/es-es/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/es-es/resources.resjson
deleted file mode 100644
index 17cce6af31a8..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/es-es/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Instalador de la herramienta Kubectl",
- "loc.helpMarkDown": "[Más información](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "Instalar Kubectl en la máquina del agente",
- "loc.instanceNameFormat": "Instalar Kubectl $(kubectlVersion)",
- "loc.input.label.kubectlVersion": "Especificación de versión de Kubectl",
- "loc.input.help.kubectlVersion": "Especifique la versión de Kubectl para instalar",
- "loc.messages.NotAValidSemverVersion": "La versión no se ha especificado en el formato correcto. Por ejemplo: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "loc.messages.VerifyKubectlInstallation": "Comprobando la instalación de kubectl..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/fr-fr/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/fr-fr/resources.resjson
deleted file mode 100644
index e2c3be995b2e..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/fr-fr/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Programme d'installation de l'outil Kubectl",
- "loc.helpMarkDown": "[Plus d'informations](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "Installer Kubectl sur une machine d'agent",
- "loc.instanceNameFormat": "Installer Kubectl $(kubectlVersion)",
- "loc.input.label.kubectlVersion": "Spécification de version de Kubectl",
- "loc.input.help.kubectlVersion": "Spécifier la version de Kubectl à installer",
- "loc.messages.NotAValidSemverVersion": "Version non spécifiée au format approprié. Exemple : 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "loc.messages.VerifyKubectlInstallation": "Vérification de l'installation de kubectl..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/it-IT/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/it-IT/resources.resjson
deleted file mode 100644
index 393b8476e735..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/it-IT/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Programma di installazione strumento Kubectl",
- "loc.helpMarkDown": "[Altre informazioni](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "Installa Kubectl nel computer agente",
- "loc.instanceNameFormat": "Installa Kubectl $(kubectlVersion)",
- "loc.input.label.kubectlVersion": "Identificatore di versione di kubectl",
- "loc.input.help.kubectlVersion": "Consente di specificare la versione di kubectl da installare",
- "loc.messages.NotAValidSemverVersion": "Il formato usato per la specifica della versione non è corretto, ad esempio 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "loc.messages.VerifyKubectlInstallation": "Verifica dell'installazione di kubectl..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/ja-jp/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/ja-jp/resources.resjson
deleted file mode 100644
index 04b60154cb26..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/ja-jp/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Kubectl ツール インストーラー",
- "loc.helpMarkDown": "[詳細情報](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "エージェント マシンに Kubectl をインストールします",
- "loc.instanceNameFormat": "Kubectl $(kubectlVersion) のインストール",
- "loc.input.label.kubectlVersion": "Kubectl バージョンの仕様",
- "loc.input.help.kubectlVersion": "インストールする Kubectl のバージョンを指定します",
- "loc.messages.NotAValidSemverVersion": "バージョンが正しい形式で指定されていません。例: 1.8.2、v1.8.2、2.8.2、v2.8.2。",
- "loc.messages.VerifyKubectlInstallation": "Kubectl のインストールを確認しています..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/ko-KR/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/ko-KR/resources.resjson
deleted file mode 100644
index caba2e045dfd..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/ko-KR/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Kubectl 도구 설치 관리자",
- "loc.helpMarkDown": "[자세한 정보](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "에이전트 머신에 Kubectl을 설치합니다.",
- "loc.instanceNameFormat": "Kubectl $(kubectlVersion) 설치",
- "loc.input.label.kubectlVersion": "Kubectl 버전 사양",
- "loc.input.help.kubectlVersion": "설치할 Kubectl 버전을 지정합니다.",
- "loc.messages.NotAValidSemverVersion": "버전이 올바른 형식으로 지정되지 않았습니다(예: 1.8.2, v1.8.2, 2.8.2, v2.8.2).",
- "loc.messages.VerifyKubectlInstallation": "Kubectl 설치를 확인하는 중..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/ru-RU/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/ru-RU/resources.resjson
deleted file mode 100644
index 7a6b04335088..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/ru-RU/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Установщик средств Kubectl",
- "loc.helpMarkDown": "[Подробнее](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "Установить Kubectl на компьютере агента",
- "loc.instanceNameFormat": "Установить Kubectl $(kubectlVersion)",
- "loc.input.label.kubectlVersion": "Спецификация версии Kubectl",
- "loc.input.help.kubectlVersion": "Укажите версию Kubectl, которую необходимо установить",
- "loc.messages.NotAValidSemverVersion": "Версия указана в неправильном формате. Примеры: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "loc.messages.VerifyKubectlInstallation": "Проверка установки kubectl..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/zh-CN/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/zh-CN/resources.resjson
deleted file mode 100644
index 6ffa1d10c0c1..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/zh-CN/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Kubectl 工具安装程序",
- "loc.helpMarkDown": "[详细信息](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "在代理计算机上安装 Kubectl",
- "loc.instanceNameFormat": "安装 Kubectl $(kubectlVersion)",
- "loc.input.label.kubectlVersion": "Kubectl 版本规范",
- "loc.input.help.kubectlVersion": "指定要安装的 Kubectl 版本",
- "loc.messages.NotAValidSemverVersion": "未指定正确格式的版本。示例: 1.8.2、v1.8.2、2.8.2、v2.8.2。",
- "loc.messages.VerifyKubectlInstallation": "正在验证 kubectl 安装..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/Strings/resources.resjson/zh-TW/resources.resjson b/Tasks/BuildctlV0/Strings/resources.resjson/zh-TW/resources.resjson
deleted file mode 100644
index 34a71b7f8979..000000000000
--- a/Tasks/BuildctlV0/Strings/resources.resjson/zh-TW/resources.resjson
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "loc.friendlyName": "Kubectl 工具安裝程式",
- "loc.helpMarkDown": "[詳細資訊](https://go.microsoft.com/fwlink/?linkid=851275)",
- "loc.description": "在代理程式機器上安裝 Kubectl",
- "loc.instanceNameFormat": "安裝 Kubectl $(kubectlVersion)",
- "loc.input.label.kubectlVersion": "Kubectl 版本規格",
- "loc.input.help.kubectlVersion": "請指定要安裝的 Kubectl 版本",
- "loc.messages.NotAValidSemverVersion": "未以正確的格式指定版本。例如: 1.8.2、v1.8.2、2.8.2、v2.8.2。",
- "loc.messages.VerifyKubectlInstallation": "正在驗證 kubectl 安裝..."
-}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/task.json b/Tasks/BuildctlV0/task.json
deleted file mode 100644
index 5422be169930..000000000000
--- a/Tasks/BuildctlV0/task.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "id": "8413C881-4959-43D5-8840-B4EA0FFC5CFE",
- "name": "BuildKitInstaller",
- "friendlyName": "Container Build Task",
- "description": "Build Task",
- "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks",
- "helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
- "category": "Tool",
- "visibility": [
- "Build",
- "Release"
- ],
- "author": "Microsoft Corporation",
- "version": {
- "Major": 0,
- "Minor": 160,
- "Patch": 1
- },
- "demands": [],
- "satisfies": [
- "Buildctl"
- ],
- "groups": [],
- "inputs": [
- {
- "name": "buildctlVersion",
- "label": "Buildctl Version Spec",
- "type": "string",
- "helpMarkDown": "Specify the version of Buildctl to install",
- "defaultValue": "latest"
- },
- {
- "name": "Dockerfile",
- "type": "filePath",
- "label": "Dockerfile",
- "defaultValue": ".",
- "required": true,
- "helpMarkDown": "Path to the Dockerfile."
- },
- {
- "name": "localContext",
- "type": "filePath",
- "label": "Build context",
- "defaultValue": ".",
- "helpMarkDown": "Path to the Build context."
- }
- ],
- "instanceNameFormat": "Container Build Task",
- "execution": {
- "Node": {
- "target": "src//buildctl.js"
- }
- },
- "messages": {
- "NotAValidSemverVersion": "Version not specified in correct format. E.g: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
- "VerifyBuildctlInstallation": "Verifying Buildctl installation...",
- "BuildctlLatestNotKnown": "Cannot get the latest Buildctl info from %s. Error %s. Using default Buildctl version %s.",
- "BuildctlDownloadFailed": "Failed to download Buildctl from location %s. Error %s",
- "BuildctlNotFoundInFolder": "Buildctl executable not found in path %s"
- }
-}
diff --git a/Tasks/BuildctlV0/task.loc.json b/Tasks/BuildctlV0/task.loc.json
deleted file mode 100644
index 3930bebcc64e..000000000000
--- a/Tasks/BuildctlV0/task.loc.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "id": "8413C881-4959-43D5-8840-B4EA0FFC5CFE",
- "name": "BuildKitInstaller",
- "friendlyName": "ms-resource:loc.friendlyName",
- "description": "ms-resource:loc.description",
- "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks",
- "helpMarkDown": "ms-resource:loc.helpMarkDown",
- "category": "Tool",
- "visibility": [
- "Build",
- "Release"
- ],
- "author": "Microsoft Corporation",
- "version": {
- "Major": 0,
- "Minor": 160,
- "Patch": 1
- },
- "demands": [],
- "satisfies": [
- "Buildctl"
- ],
- "groups": [],
- "inputs": [
- {
- "name": "buildctlVersion",
- "label": "ms-resource:loc.input.label.buildctlVersion",
- "type": "string",
- "helpMarkDown": "ms-resource:loc.input.help.buildctlVersion",
- "defaultValue": "latest"
- },
- {
- "name": "Dockerfile",
- "type": "filePath",
- "label": "ms-resource:loc.input.label.Dockerfile",
- "defaultValue": ".",
- "required": true,
- "helpMarkDown": "ms-resource:loc.input.help.Dockerfile"
- },
- {
- "name": "localContext",
- "type": "filePath",
- "label": "ms-resource:loc.input.label.localContext",
- "defaultValue": ".",
- "helpMarkDown": "ms-resource:loc.input.help.localContext"
- }
- ],
- "instanceNameFormat": "ms-resource:loc.instanceNameFormat",
- "execution": {
- "Node": {
- "target": "src//buildctl.js"
- }
- },
- "messages": {
- "NotAValidSemverVersion": "ms-resource:loc.messages.NotAValidSemverVersion",
- "VerifyBuildctlInstallation": "ms-resource:loc.messages.VerifyBuildctlInstallation",
- "BuildctlLatestNotKnown": "ms-resource:loc.messages.BuildctlLatestNotKnown",
- "BuildctlDownloadFailed": "ms-resource:loc.messages.BuildctlDownloadFailed",
- "BuildctlNotFoundInFolder": "ms-resource:loc.messages.BuildctlNotFoundInFolder"
- }
-}
\ No newline at end of file
diff --git a/Tasks/ContainerBuildV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/ContainerBuildV0/Strings/resources.resjson/en-US/resources.resjson
new file mode 100644
index 000000000000..1f422fcda272
--- /dev/null
+++ b/Tasks/ContainerBuildV0/Strings/resources.resjson/en-US/resources.resjson
@@ -0,0 +1,27 @@
+{
+ "loc.friendlyName": "Container Build",
+ "loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
+ "loc.description": "Build Task",
+ "loc.instanceNameFormat": "Container Build Task",
+ "loc.group.displayName.containerRepository": "Container Repository",
+ "loc.group.displayName.commands": "Commands",
+ "loc.input.label.dockerRegistryServiceConnection": "Docker registry service connection",
+ "loc.input.help.dockerRegistryServiceConnection": "Select a Docker registry service connection. Required for commands that need to authenticate with a registry.",
+ "loc.input.label.repository": "Container repository",
+ "loc.input.help.repository": "Name of the repository.",
+ "loc.input.label.Dockerfile": "Dockerfile",
+ "loc.input.help.Dockerfile": "Path to the Dockerfile.",
+ "loc.input.label.buildContext": "Build context",
+ "loc.input.help.buildContext": "Path to the Build context.",
+ "loc.input.label.tags": "Tags",
+ "loc.input.help.tags": "A list of tags in separate lines. These tags are used in build, push and buildAndPush commands. Ex:
beta1.1
latest",
+ "loc.input.label.arguments": "Arguments",
+ "loc.input.help.arguments": "Docker command options. Ex:
For build command,
--build-arg HTTP_PROXY=http://10.20.30.2:1234 --quiet",
+ "loc.input.label.addPipelineData": "Add Pipeline metadata to image(s)",
+ "loc.input.help.addPipelineData": "By default pipeline data like source branch name, build id are added which helps with traceability. For example you can inspect an image to find out which pipeline built the image. You can opt out of this default behavior by using this input.",
+ "loc.messages.NotAValidSemverVersion": "Version not specified in correct format. E.g: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
+ "loc.messages.VerifyBuildctlInstallation": "Verifying Buildctl installation...",
+ "loc.messages.BuildctlLatestNotKnown": "Cannot get the latest Buildctl info from %s. Error %s. Using default Buildctl version %s.",
+ "loc.messages.BuildctlDownloadFailed": "Failed to download Buildctl from location %s. Error %s",
+ "loc.messages.BuildctlNotFoundInFolder": "Buildctl executable not found in path %s"
+}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/ThirdPartyNotices.txt b/Tasks/ContainerBuildV0/ThirdPartyNotices.txt
similarity index 100%
rename from Tasks/BuildctlV0/ThirdPartyNotices.txt
rename to Tasks/ContainerBuildV0/ThirdPartyNotices.txt
diff --git a/Tasks/BuildctlV0/icon.png b/Tasks/ContainerBuildV0/icon.png
similarity index 100%
rename from Tasks/BuildctlV0/icon.png
rename to Tasks/ContainerBuildV0/icon.png
diff --git a/Tasks/BuildctlV0/icon.svg b/Tasks/ContainerBuildV0/icon.svg
similarity index 100%
rename from Tasks/BuildctlV0/icon.svg
rename to Tasks/ContainerBuildV0/icon.svg
diff --git a/Tasks/BuildctlV0/make.json b/Tasks/ContainerBuildV0/make.json
similarity index 100%
rename from Tasks/BuildctlV0/make.json
rename to Tasks/ContainerBuildV0/make.json
diff --git a/Tasks/BuildctlV0/package-lock.json b/Tasks/ContainerBuildV0/package-lock.json
similarity index 100%
rename from Tasks/BuildctlV0/package-lock.json
rename to Tasks/ContainerBuildV0/package-lock.json
diff --git a/Tasks/BuildctlV0/package.json b/Tasks/ContainerBuildV0/package.json
similarity index 100%
rename from Tasks/BuildctlV0/package.json
rename to Tasks/ContainerBuildV0/package.json
diff --git a/Tasks/BuildctlV0/src/buildctl.ts b/Tasks/ContainerBuildV0/src/buildctl.ts
similarity index 81%
rename from Tasks/BuildctlV0/src/buildctl.ts
rename to Tasks/ContainerBuildV0/src/buildctl.ts
index 79e54f0b7f5f..01c217eae566 100644
--- a/Tasks/BuildctlV0/src/buildctl.ts
+++ b/Tasks/ContainerBuildV0/src/buildctl.ts
@@ -5,11 +5,10 @@ import path = require('path');
import * as toolLib from 'azure-pipelines-tool-lib/tool';
import utils = require("./utils");
-
tl.setResourcePath(path.join(__dirname, '..', 'task.json'));
async function configureBuildctl() {
- var stableBuildKitVersion = await utils.getBuildctlVersion();
+ var stableBuildKitVersion = await utils.getStableBuildctlVersion();
var buildctlPath = await utils.downloadBuildctl(stableBuildKitVersion);
// prepend the tools path. instructs the agent to prepend for future tasks
@@ -20,41 +19,45 @@ async function configureBuildctl() {
async function verifyBuildctl() {
tl.debug(tl.loc("VerifyBuildctlInstallation"));
+
var buildctlToolPath = tl.which("buildctl", true);
var buildctlTool = tl.tool(buildctlToolPath);
+
buildctlTool.arg("--help");
buildctlTool.exec();
}
async function buildContainer() {
- if(process.env["RUNNING_AS_K8_POOLPROVIDER"] == "1") {
+ if(process.env["RUNNING_ON"] == "KUBERNETES") {
+
tl.debug("Container building using buildctl");
return buildUsingBuildctl();
+
}
else {
+
tl.debug("Container building using docker frontend");
return buildUsingDocker();
- }
+ }
}
async function buildUsingBuildctl() {
await verifyBuildctl();
- const dockerfilepath = tl.getInput("dockerFile", true);
- const contextpath = tl.getInput("localContext", true);
- var podname = await utils.getBuildKitPod();
- tl.debug("Podname " +podname);
- process.env["BUILDKIT_HOST"] = "kube-pod://"+podname+"?namespace=azuredevops";
+
+ await utils.getBuildKitPod();
+
+ var contextarg = "--local=context="+tl.getInput("buildContext", true);
+ var dockerfilearg = "--local=dockerfile="+tl.getInput("dockerFile", true);
var buildctlToolPath = tl.which("buildctl", true);
var buildctlTool = tl.tool(buildctlToolPath);
+
buildctlTool.arg("build");
buildctlTool.arg('--frontend=dockerfile.v0');
-
- var contextarg = "--local=context="+contextpath;
- var dockerfilearg = "--local=dockerfile="+dockerfilepath;
buildctlTool.arg(contextarg);
buildctlTool.arg(dockerfilearg);
+
return buildctlTool.exec();
}
@@ -62,11 +65,12 @@ async function buildUsingDocker() {
const dockerfilepath = tl.getInput("dockerFile", true);
const contextpath = tl.getInput("localContext", true);
+
var dockerToolPath = tl.which("docker", true);
var command = tl.tool(dockerToolPath);
+
command.arg("build");
command.arg(["-f", dockerfilepath]);
-
command.arg(contextpath);
// setup variable to store the command output
diff --git a/Tasks/BuildctlV0/src/utils.ts b/Tasks/ContainerBuildV0/src/utils.ts
similarity index 71%
rename from Tasks/BuildctlV0/src/utils.ts
rename to Tasks/ContainerBuildV0/src/utils.ts
index d9ca91faa72a..d9b367bccc0c 100644
--- a/Tasks/BuildctlV0/src/utils.ts
+++ b/Tasks/ContainerBuildV0/src/utils.ts
@@ -12,16 +12,12 @@ const buildctlToolName = "buildctl"
const uuidV4 = require('uuid/v4');
const buildctlLatestReleaseUrl = "https://api.github.com/repos/moby/buildkit/releases/latest";
const stableBuildctlVersion = "v0.5.1"
+const serviceidentifier = "k8loadbalancer"
+var namespace = "azuredevops"
+var port = "8082"
+var clusteruri = ""
-export async function getBuildctlVersion(): Promise {
- let buildctlVersion = tl.getInput("buildctlVersion");
- if(buildctlVersion && buildctlVersion != "latest") {
- return sanitizeVersionString(buildctlVersion.trim());
- }
- return await getStableBuildctlVersion();
-}
-
-async function getStableBuildctlVersion(): Promise {
+export async function getStableBuildctlVersion(): Promise {
var request = new webclient.WebRequest();
request.uri = buildctlLatestReleaseUrl;
request.method = "GET";
@@ -36,8 +32,10 @@ async function getStableBuildctlVersion(): Promise {
return stableBuildctlVersion;
}
export async function downloadBuildctl(version: string): Promise {
- var cachedToolpath = toolLib.findLocalTool(buildctlToolName, version);
+
let buildctlDownloadPath: string = null;
+ var cachedToolpath = toolLib.findLocalTool(buildctlToolName, version);
+
if (!cachedToolpath) {
try {
buildctlDownloadPath = await toolLib.downloadTool(getBuildctlDownloadURL(version), buildctlToolName + "-" + version + "-" + uuidV4() + getArchiveExtension());
@@ -47,8 +45,11 @@ export async function downloadBuildctl(version: string): Promise {
var unzipedBuildctlPath = await toolLib.extractTar(buildctlDownloadPath);
unzipedBuildctlPath = path.join(unzipedBuildctlPath, "bin", buildctlToolName);
+
tl.debug('Extracting archive: ' + unzipedBuildctlPath+' download path: '+buildctlDownloadPath);
+
var cachedToolpath = await toolLib.cacheFile(unzipedBuildctlPath, buildctlToolName, buildctlToolName, version);
+
tl.debug('CachedTool path: ' + cachedToolpath);
}
@@ -56,7 +57,9 @@ export async function downloadBuildctl(version: string): Promise {
if (!buildctlpath) {
throw new Error(tl.loc("BuildctlNotFoundInFolder", cachedToolpath))
}
+
tl.debug('Buildctl path: ' + buildctlpath);
+
fs.chmodSync(buildctlpath, "777");
return buildctlpath;
}
@@ -76,54 +79,55 @@ function getBuildctlDownloadURL(version: string): string {
}
}
-export async function getBuildKitPod(): Promise {
+export async function getServiceDetails() {
- var consistenthashkey = tl.getVariable('Build.Repository.Name')+tl.getInput("dockerFile", true);
var kubectlToolPath = tl.which("kubectl", true);
var kubectlTool = tl.tool(kubectlToolPath);
+
kubectlTool.arg('get');
- kubectlTool.arg('services');
- kubectlTool.arg('k8s-poolprovider');
- kubectlTool.arg('-n=azuredevops');
+ kubectlTool.arg('service');
+ kubectlTool.arg(`--selector=identifier=${serviceidentifier}`);
kubectlTool.arg('-o=json');
+
var serviceResponse= kubectlTool.execSync();
-
- //console.log("PodName: "+ JSON.parse(serviceResponse.stdout).status.loadBalancer.ingress[0].ip);
- var clusteruri = "http://"+JSON.parse(serviceResponse.stdout).status.loadBalancer.ingress[0].ip+":8082/consistenthash";
+
+ namespace = JSON.parse(serviceResponse.stdout).items[0].metadata.namespace;
+ port = JSON.parse(serviceResponse.stdout).items[0].spec.ports[0].port;
+ clusteruri = JSON.parse(serviceResponse.stdout).items[0].status.loadBalancer.ingress[0].ip;
+}
+
+export async function getBuildKitPod() {
+
+ await getServiceDetails();
+
let request = new webclient.WebRequest();
-
- request.uri = clusteruri;
let headers = {
- "key": consistenthashkey
+ "key": tl.getVariable('Build.Repository.Name')+tl.getInput("dockerFile", true)
};
+ let webRequestOptions:webclient.WebRequestOptions = {retriableErrorCodes: [], retriableStatusCodes: [], retryCount: 1, retryIntervalInSeconds: 5, retryRequestTimedout: true};
+
+ request.uri = `http://${clusteruri}:${port}/getBuildPod`;
request.headers = headers
request.method = "GET";
-
- //console.log("Get releases request: " + JSON.stringify(request));
- let webRequestOptions:webclient.WebRequestOptions = {retriableErrorCodes: [], retriableStatusCodes: [], retryCount: 1, retryIntervalInSeconds: 5, retryRequestTimedout: true};
var response = await webclient.sendRequest(request, webRequestOptions);
- //console.log(response.body);
var podname = response.body.Message;
- return podname;
+
+ tl.debug("Podname " +podname);
+
+ // set the environment variable
+ process.env["BUILDKIT_HOST"] = "kube-pod://"+podname+"?namespace="+namespace;
}
function findBuildctl(rootFolder: string) {
- var DockerPath = path.join(rootFolder, buildctlToolName);
- tl.debug('inside findBuildctl path: ' + DockerPath);
+
+ var BuildctlPath = path.join(rootFolder, buildctlToolName);
var allPaths = tl.find(rootFolder);
- var matchingResultsFiles = tl.match(allPaths, DockerPath, rootFolder);
- return matchingResultsFiles[0];
-}
+ var matchingResultsFiles = tl.match(allPaths, BuildctlPath, rootFolder);
-// handle user input scenerios
-export function sanitizeVersionString(inputVersion: string) : string{
- var version = toolLib.cleanVersion(inputVersion);
- if(!version) {
- throw new Error(tl.loc("NotAValidSemverVersion"));
- }
+ tl.debug('inside findBuildctl path: ' + BuildctlPath);
- return "v"+version;
+ return matchingResultsFiles[0];
}
function getArchiveExtension(): string {
diff --git a/Tasks/ContainerBuildV0/task.json b/Tasks/ContainerBuildV0/task.json
new file mode 100644
index 000000000000..2d32e98c3036
--- /dev/null
+++ b/Tasks/ContainerBuildV0/task.json
@@ -0,0 +1,111 @@
+{
+ "id": "8413C881-4959-43D5-8840-B4EA0FFC5CFE",
+ "name": "ContainerBuild",
+ "friendlyName": "Container Build",
+ "description": "Build Task",
+ "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks",
+ "helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
+ "category": "Build",
+ "visibility": [
+ "Build",
+ "Release"
+ ],
+ "author": "Microsoft Corporation",
+ "version": {
+ "Major": 0,
+ "Minor": 160,
+ "Patch": 1
+ },
+ "demands": [],
+ "satisfies": [
+ "Buildctl"
+ ],
+ "groups": [
+ {
+ "name": "containerRepository",
+ "displayName": "Container Repository",
+ "isExpanded": true
+ },
+ {
+ "name": "commands",
+ "displayName": "Commands",
+ "isExpanded": true
+ }
+ ],
+ "inputs": [
+ {
+ "name": "dockerRegistryServiceConnection",
+ "type": "connectedService:dockerregistry",
+ "label": "Docker registry service connection",
+ "groupName": "containerRepository",
+ "helpMarkDown": "Select a Docker registry service connection. Required for commands that need to authenticate with a registry."
+ },
+ {
+ "name": "repository",
+ "label": "Container repository",
+ "type": "string",
+ "helpMarkDown": "Name of the repository.",
+ "defaultValue": "",
+ "visibleRule": "command != login && command != logout",
+ "groupName": "containerRepository",
+ "properties": {
+ "EditableOptions": "True"
+ }
+ },
+ {
+ "name": "Dockerfile",
+ "type": "filePath",
+ "label": "Dockerfile",
+ "defaultValue": ".",
+ "required": true,
+ "helpMarkDown": "Path to the Dockerfile."
+ },
+ {
+ "name": "buildContext",
+ "type": "filePath",
+ "label": "Build context",
+ "defaultValue": ".",
+ "helpMarkDown": "Path to the Build context."
+ },
+ {
+ "name": "tags",
+ "type": "multiLine",
+ "defaultValue": "$(Build.BuildId)",
+ "properties": {
+ "resizable": "true",
+ "rows": "2"
+ },
+ "label": "Tags",
+ "groupName": "commands",
+ "helpMarkDown": "A list of tags in separate lines. These tags are used in build, push and buildAndPush commands. Ex:
beta1.1
latest"
+ },
+ {
+ "name": "arguments",
+ "type": "string",
+ "label": "Arguments",
+ "groupName": "commands",
+ "helpMarkDown": "Docker command options. Ex:
For build command,
--build-arg HTTP_PROXY=http://10.20.30.2:1234 --quiet"
+ },
+ {
+ "name": "addPipelineData",
+ "type": "boolean",
+ "label": "Add Pipeline metadata to image(s)",
+ "groupName": "commands",
+ "defaultValue": "true",
+ "helpMarkDown": "By default pipeline data like source branch name, build id are added which helps with traceability. For example you can inspect an image to find out which pipeline built the image. You can opt out of this default behavior by using this input."
+ }
+ ],
+ "instanceNameFormat": "Container Build Task",
+ "execution": {
+ "Node": {
+ "target": "src//buildctl.js"
+ }
+ },
+ "messages": {
+ "NotAValidSemverVersion": "Version not specified in correct format. E.g: 1.8.2, v1.8.2, 2.8.2, v2.8.2.",
+ "VerifyBuildctlInstallation": "Verifying Buildctl installation...",
+ "BuildctlLatestNotKnown": "Cannot get the latest Buildctl info from %s. Error %s. Using default Buildctl version %s.",
+ "BuildctlDownloadFailed": "Failed to download Buildctl from location %s. Error %s",
+ "BuildctlNotFoundInFolder": "Buildctl executable not found in path %s"
+ }
+}
diff --git a/Tasks/ContainerBuildV0/task.loc.json b/Tasks/ContainerBuildV0/task.loc.json
new file mode 100644
index 000000000000..d6ef2e472af3
--- /dev/null
+++ b/Tasks/ContainerBuildV0/task.loc.json
@@ -0,0 +1,111 @@
+{
+ "id": "8413C881-4959-43D5-8840-B4EA0FFC5CFE",
+ "name": "ContainerBuild",
+ "friendlyName": "ms-resource:loc.friendlyName",
+ "description": "ms-resource:loc.description",
+ "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks",
+ "helpMarkDown": "ms-resource:loc.helpMarkDown",
+ "category": "Build",
+ "visibility": [
+ "Build",
+ "Release"
+ ],
+ "author": "Microsoft Corporation",
+ "version": {
+ "Major": 0,
+ "Minor": 160,
+ "Patch": 1
+ },
+ "demands": [],
+ "satisfies": [
+ "Buildctl"
+ ],
+ "groups": [
+ {
+ "name": "containerRepository",
+ "displayName": "ms-resource:loc.group.displayName.containerRepository",
+ "isExpanded": true
+ },
+ {
+ "name": "commands",
+ "displayName": "ms-resource:loc.group.displayName.commands",
+ "isExpanded": true
+ }
+ ],
+ "inputs": [
+ {
+ "name": "dockerRegistryServiceConnection",
+ "type": "connectedService:dockerregistry",
+ "label": "ms-resource:loc.input.label.dockerRegistryServiceConnection",
+ "groupName": "containerRepository",
+ "helpMarkDown": "ms-resource:loc.input.help.dockerRegistryServiceConnection"
+ },
+ {
+ "name": "repository",
+ "label": "ms-resource:loc.input.label.repository",
+ "type": "string",
+ "helpMarkDown": "ms-resource:loc.input.help.repository",
+ "defaultValue": "",
+ "visibleRule": "command != login && command != logout",
+ "groupName": "containerRepository",
+ "properties": {
+ "EditableOptions": "True"
+ }
+ },
+ {
+ "name": "Dockerfile",
+ "type": "filePath",
+ "label": "ms-resource:loc.input.label.Dockerfile",
+ "defaultValue": ".",
+ "required": true,
+ "helpMarkDown": "ms-resource:loc.input.help.Dockerfile"
+ },
+ {
+ "name": "buildContext",
+ "type": "filePath",
+ "label": "ms-resource:loc.input.label.buildContext",
+ "defaultValue": ".",
+ "helpMarkDown": "ms-resource:loc.input.help.buildContext"
+ },
+ {
+ "name": "tags",
+ "type": "multiLine",
+ "defaultValue": "$(Build.BuildId)",
+ "properties": {
+ "resizable": "true",
+ "rows": "2"
+ },
+ "label": "ms-resource:loc.input.label.tags",
+ "groupName": "commands",
+ "helpMarkDown": "ms-resource:loc.input.help.tags"
+ },
+ {
+ "name": "arguments",
+ "type": "string",
+ "label": "ms-resource:loc.input.label.arguments",
+ "groupName": "commands",
+ "helpMarkDown": "ms-resource:loc.input.help.arguments"
+ },
+ {
+ "name": "addPipelineData",
+ "type": "boolean",
+ "label": "ms-resource:loc.input.label.addPipelineData",
+ "groupName": "commands",
+ "defaultValue": "true",
+ "helpMarkDown": "ms-resource:loc.input.help.addPipelineData"
+ }
+ ],
+ "instanceNameFormat": "ms-resource:loc.instanceNameFormat",
+ "execution": {
+ "Node": {
+ "target": "src//buildctl.js"
+ }
+ },
+ "messages": {
+ "NotAValidSemverVersion": "ms-resource:loc.messages.NotAValidSemverVersion",
+ "VerifyBuildctlInstallation": "ms-resource:loc.messages.VerifyBuildctlInstallation",
+ "BuildctlLatestNotKnown": "ms-resource:loc.messages.BuildctlLatestNotKnown",
+ "BuildctlDownloadFailed": "ms-resource:loc.messages.BuildctlDownloadFailed",
+ "BuildctlNotFoundInFolder": "ms-resource:loc.messages.BuildctlNotFoundInFolder"
+ }
+}
\ No newline at end of file
diff --git a/Tasks/BuildctlV0/tsconfig.json b/Tasks/ContainerBuildV0/tsconfig.json
similarity index 100%
rename from Tasks/BuildctlV0/tsconfig.json
rename to Tasks/ContainerBuildV0/tsconfig.json