diff --git a/Tasks/code-push-vsts-task/CodePush.js b/Tasks/code-push-vsts-task/CodePush.js index b6639eb..be33f00 100644 --- a/Tasks/code-push-vsts-task/CodePush.js +++ b/Tasks/code-push-vsts-task/CodePush.js @@ -61,7 +61,15 @@ function ensureLoggedOut() { // The main function to be executed. function performDeployTask(accessKey, appName, packagePath, appStoreVersion, deploymentName, description, isMandatory) { // If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS. - accessKey = accessKey || tl.getInput("accessKey", true); + var authType = tl.getInput("authType", false); + if (authType === "AccessKey") { + tl.getInput("accessKey", true); + } else if (authType === "ServiceEndpoint") { + var serviceAccount = tl.getEndpointAuthorization(tl.getInput("serviceEndpoint", true)); + accessKey = serviceAccount.parameters.password; + } + + accessKey = accessKey; appName = appName || tl.getInput("appName", true); packagePath = packagePath || tl.getPathInput("packagePath", true); appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", true); @@ -70,8 +78,8 @@ function performDeployTask(accessKey, appName, packagePath, appStoreVersion, dep isMandatory = isMandatory || tl.getInput("isMandatory", false); if (!accessKey) { - var serviceAccount = tl.getEndpointAuthorization(tl.getInput("serviceAccount", true)); - accessKey = serviceAccount.password; + console.error("Access key required"); + tl.setResult(1, "Access key required"); } // Ensure all other users are logged out. diff --git a/Tasks/code-push-vsts-task/CodePush.ps1 b/Tasks/code-push-vsts-task/CodePush.ps1 index 74cd46c..7dd6d49 100644 --- a/Tasks/code-push-vsts-task/CodePush.ps1 +++ b/Tasks/code-push-vsts-task/CodePush.ps1 @@ -1,5 +1,6 @@ param ( [string]$accessKey, + [string]$serviceEndpoint, [string]$appName, [string]$packagePath, [string]$appStoreVersion, @@ -9,6 +10,7 @@ param ( ) $env:INPUT_accessKey = $accessKey +$env:INPUT_serviceEndpoint = $serviceEndpoint $env:INPUT_appName = $appName $env:INPUT_packagePath = $packagePath $env:INPUT_appStoreVersion = $appStoreVersion diff --git a/Tasks/code-push-vsts-task/task.json b/Tasks/code-push-vsts-task/task.json index 2c2c47f..4e6669b 100644 --- a/Tasks/code-push-vsts-task/task.json +++ b/Tasks/code-push-vsts-task/task.json @@ -22,21 +22,21 @@ "name": "authType", "type": "pickList", "label": "Authentication Method", - "defaultValue": "ServiceAccount", + "defaultValue": "ServiceEndpoint", "helpMarkDown": "", "options": { - "ServiceAccount": "Service Account", + "ServiceEndpoint": "Service Endpoint", "AccessKey": "Access Key" } }, { - "name": "serviceAccount", - "type": "connectedService:code-push", - "label": "Service Account", + "name": "serviceEndpoint", + "type": "connectedService:codepush-auth-key", + "label": "Service Endpoint", "defaultValue": "", "required": true, - "helpMarkDown": "The VSTS Service Account that specifies the idenity for Code Push.", - "visibleRule": "authType = ServiceAccount" + "helpMarkDown": "The VSTS Service Endpoint that specifies the identity for Code Push.", + "visibleRule": "authType = ServiceEndpoint" }, { "name": "accessKey", diff --git a/makevsix.sh b/makevsix.sh old mode 100644 new mode 100755 index 257cfab..791d3b4 --- a/makevsix.sh +++ b/makevsix.sh @@ -20,15 +20,15 @@ node bin/tfxupload.js --installonly if [ $1 == "create" ] ; then echo "Creating VSIX..." - tfx extension create --manifest-globs vso-extension-android.json --override '{ "public": true }' + tfx extension create --manifest-globs vsts-extension-code-push.json --override '{ "public": true }' fi if [ $1 == "createtest" ] ; then echo "Creating Test VSIX..." - tfx extension create --manifest-globs vso-extension-android.json --override '{ "public": "false", "name": "Google Play Store Deploy-Dev", "id": "vso-extension-android-dev", "publisher": "ms-mobiledevops-test"}' --share-with mobiledevops x04ty29er --token $PUBLISH_ACCESSTOKEN + tfx extension create --manifest-globs vsts-extension-code-push.json --override '{ "public": "false", "name": "CodePush-Dev", "id": "code-push-dev", "publisher": "ms-mobiledevops-test"}' --share-with mobiledevops x04ty29er --token $PUBLISH_ACCESSTOKEN fi if [ $1 == "publishtest" ] ; then echo "Creating and publishing test VSIX..." - tfx extension publish --manifest-globs vso-extension-android.json --override '{ "public": "false", "name": "Google Play Store Deploy-Dev", "id": "vso-extension-android-dev", "publisher": "ms-mobiledevops-test"}' --share-with mobiledevops x04ty29er --token $PUBLISH_ACCESSTOKEN + tfx extension publish --manifest-globs vsts-extension-code-push.json --override '{ "public": "false", "name": "CodePush-Dev", "id": "code-push-dev", "publisher": "ms-mobiledevops-test"}' --share-with mobiledevops x04ty29er --token $PUBLISH_ACCESSTOKEN fi \ No newline at end of file diff --git a/vsts-extension-code-push.json b/vsts-extension-code-push.json index a978b9a..9b636ed 100644 --- a/vsts-extension-code-push.json +++ b/vsts-extension-code-push.json @@ -4,13 +4,18 @@ "name": "CodePush", "version": "1.0.1", "publisher": "ms-vsclient", - "public": true, "description": "Provides a deploy task that enables performing continuous delivery to the CodePush service from an automated VSTS build definition", "categories": [ "Build and release" ], - "scopes": [ - "vso.build" + "targets": [ + { + "id": "Microsoft.VisualStudio.Services" + } + ], + "scope": [ + "vso.build", + "vso.serviceendpoint" ], "tags": [ "Cordova", "React Native", "CodePush", "Deploy", "Continuous Integration", "Continuous Delivery", "Android", "iOS" @@ -39,12 +44,12 @@ "path": "docs/extension-overview.md" }, "thirdpartynotice": { - "path": "thirdpartynotices.txt" + "path": "ThirdPartyNotices.txt" } }, "files": [ { - "path": "code-push-vsts-task" + "path": "Tasks/code-push-vsts-task" }, { "path": "images", @@ -57,20 +62,20 @@ "type": "ms.vss-distributed-task.task", "targets": [ "ms.vss-distributed-task.tasks" ], "properties": { - "name": "code-push-vsts-task" + "name": "Tasks/code-push-vsts-task" } }, { - "id": "code-push-service-endpoint", + "id": "codepush-service-endpoint", "description": "CodePushAuthenticationEndpoint", "type": "ms.vss-endpoint.service-endpoint-type", "targets": [ "ms.vss-endpoint.endpoint-types" ], "properties": { - "name": "code-push", + "name": "codepush-auth-key", "displayName": "Code Push", - "url": "https://microsoft.github.io/code-push", + "url": "https://accounts.google.com/o/oauth2/v2/auth", "inputDescriptors": [], "authenticationSchemes": [ { @@ -79,21 +84,23 @@ { "id": "username", "name": "Username", - "description": "", + "description": "Username", "inputMode": "textbox", "isConfidential": false, "validation": { - "isRequired": true, + "isRequired": false, "dataType": "string" }, "values": { + "inputId": "usernameInput", + "defaultValue": "", "isDisabled": true } }, { "id": "password", "name": "Access Key", - "description": "Access Key from Code Push CLI", + "description": "Access key from CodePush CLI.", "inputMode": "textbox", "isConfidential": true, "validation": {