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
58 changes: 29 additions & 29 deletions .azure-pipelines/common-steps.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Common steps template
#
# Things which happen regardless of CI, PR, or release builds
steps:
- checkout: self
clean: true
- task: NodeTool@0
displayName: Use node 10
inputs:
versionSpec: "10.x"
- task: NpmAuthenticate@0
inputs:
workingFile: .npmrc
- script: npm i -g npm@6.14.12 --force
displayName: Use npm version 6.14.12
- bash: |
npm ci
npm run build
displayName: Build TFX CLI
# Generate a pipeline artifact so we can publish the package manually if there are issues with automation
- bash: |
npm pack
cp *.tgz '$(Build.ArtifactStagingDirectory)'
displayName: Run npm-pack and copy to ArtifactStagingDirectory
# Common steps template
#
# Things which happen regardless of CI, PR, or release builds
steps:
- checkout: self
clean: true

- task: NodeTool@0
displayName: Use node 10
inputs:
versionSpec: "10.x"

- task: NpmAuthenticate@0
inputs:
workingFile: .npmrc

- script: npm i -g npm@6.14.12 --force
displayName: Use npm version 6.14.12

- bash: |
npm ci
npm run build
displayName: Build TFX CLI

# Generate a pipeline artifact so we can publish the package manually if there are issues with automation
- bash: |
npm pack
cp *.tgz '$(Build.ArtifactStagingDirectory)'
displayName: Run npm-pack and copy to ArtifactStagingDirectory
217 changes: 109 additions & 108 deletions .azure-pipelines/release-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,109 @@
# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
# This pipeline will be extended to the OneESPT template

trigger: none

variables:
- group: npm-tokens
resources:
repositories:
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
settings:
skipBuildTagsForGitHubPullRequests: true

pool:
name: 1ES-ABTT-Shared-Pool
image: abtt-windows-2022
os: windows
stages:
- stage: Build
displayName: Build the tfx-cli npm package
jobs:
- job: build
templateContext:
outputs:
- output: pipelineArtifact
displayName: 'Publish tfx-cli package to pipeline artifacts'
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactType: 'pipeline'
artifactName: 'tfx-cli-package'
steps:
- template: /.azure-pipelines/common-steps.yml@self
- ${{ if in(variables['build.reason'], 'IndividualCI', 'BatchedCI', 'Manual') }}:
# Validate and publish packages
# The npm cli will replace ${NPM_TOKEN} with the contents of the NPM_TOKEN environment variable.
- bash: |
echo '//registry.npmjs.org/:_authToken=$(npm-automation.token)' > .npmrc

npm publish --ignore-scripts --tag prerelease
exit_status=$?
if [ $exit_status -eq 1 ]; then
echo "##vso[task.logissue type=warning]Publishing TFX CLI was unsuccessful"
echo "##vso[task.complete result=SucceededWithIssues;]"
fi

rm .npmrc
displayName: Publish TFX CLI to npm
condition: eq(variables['Build.SourceBranchName'], 'master')

# Install node 16 for CodeQL 3000
- task: NodeTool@0
displayName: Use node 16
inputs:
versionSpec: "16.x"
- stage: Release
displayName: Release to Latest
trigger: manual
jobs:
- job: Release
displayName: Release to Latest
steps:
- checkout: self
clean: true

- task: NodeTool@0
displayName: Use node 16
inputs:
versionSpec: "16.x"
- script: npm i -g npm@8.19.4 --force
displayName: Use npm version 8.19.4

- bash: |
echo '//registry.npmjs.org/:_authToken=$(npm-automation.token)' > .npmrc
# Run the npm command and capture the output
output=$(npm pkg get name version)
echo "${output}"

# Extract the name and version values using shell parameter expansion
name=$(echo "$output" | grep -o '"name":\s*"[^"]*"' | sed 's/"name":\s*"\([^"]*\)"/\1/')
version=$(echo "$output" | grep -o '"version":\s*"[^"]*"' | sed 's/"version":\s*"\([^"]*\)"/\1/')

# Save them in a variable in the format name@version
result="${name}@${version}"

# Combine them in the format name@version
echo "${result}"

npm dist-tag add "$result" latest
exit_status=$?
if [ $exit_status -eq 1 ]; then
echo "##vso[task.logissue type=error]Upgrading TFX CLI to latest was unsuccessful"
echo "##vso[task.complete result=Failed;]"
exit 1
fi

npm dist-tag remove "$result" prerelease
exit_status=$?
if [ $exit_status -eq 1 ]; then
echo "##vso[task.logissue type=error]Removing prerelease for TFX CLI was unsuccessful"
echo "##vso[task.complete result=SucceededWithIssues;]"
fi
rm .npmrc
displayName: Publish TFX CLI to npm
# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
# This pipeline will be extended to the OneESPT template

trigger: none

variables:
- group: npm-tokens
resources:
repositories:
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
settings:
skipBuildTagsForGitHubPullRequests: true

pool:
name: 1ES-ABTT-Shared-Pool
image: abtt-windows-2022
os: windows
stages:
- stage: Build
displayName: Build the tfx-cli npm package
jobs:
- job: build
templateContext:
outputs:
- output: pipelineArtifact
displayName: 'Publish tfx-cli package to pipeline artifacts'
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactType: 'pipeline'
artifactName: 'tfx-cli-package'
steps:
- template: /.azure-pipelines/common-steps.yml@self
- ${{ if in(variables['build.reason'], 'IndividualCI', 'BatchedCI', 'Manual') }}:
# Validate and publish packages
# The npm cli will replace ${NPM_TOKEN} with the contents of the NPM_TOKEN environment variable.
- bash: |
echo '//registry.npmjs.org/:_authToken=$(npm-automation.token)' > .npmrc

npm publish --ignore-scripts --tag prerelease
exit_status=$?
if [ $exit_status -eq 1 ]; then
echo "##vso[task.logissue type=warning]Publishing TFX CLI was unsuccessful"
echo "##vso[task.complete result=SucceededWithIssues;]"
fi

rm .npmrc
displayName: Publish TFX CLI to npm
condition: eq(variables['Build.SourceBranchName'], 'master')

# Install node 16 for CodeQL 3000
- task: NodeTool@0
displayName: Use node 16
inputs:
versionSpec: "16.x"
- stage: Release
displayName: Release to Latest
trigger: manual
jobs:
- job: Release
displayName: Release to Latest
steps:
- checkout: self
clean: true

- task: NodeTool@0
displayName: Use node 16
inputs:
versionSpec: "16.x"
- script: npm i -g npm@8.19.4 --force
displayName: Use npm version 8.19.4

- bash: |
echo '//registry.npmjs.org/:_authToken=$(npm-automation.token)' > .npmrc
# Run the npm command and capture the output
output=$(npm pkg get name version)
echo "${output}"

# Extract the name and version values using shell parameter expansion
name=$(echo "$output" | grep -o '"name":\s*"[^"]*"' | sed 's/"name":\s*"\([^"]*\)"/\1/')
version=$(echo "$output" | grep -o '"version":\s*"[^"]*"' | sed 's/"version":\s*"\([^"]*\)"/\1/')

# Save them in a variable in the format name@version
result="${name}@${version}"

# Combine them in the format name@version
echo "${result}"

npm dist-tag add "$result" latest
exit_status=$?
if [ $exit_status -eq 1 ]; then
echo "##vso[task.logissue type=error]Upgrading TFX CLI to latest was unsuccessful"
echo "##vso[task.complete result=Failed;]"
exit 1
fi

npm dist-tag remove "$result" prerelease
exit_status=$?
if [ $exit_status -eq 1 ]; then
echo "##vso[task.logissue type=error]Removing prerelease for TFX CLI was unsuccessful"
echo "##vso[task.complete result=SucceededWithIssues;]"
fi
rm .npmrc
displayName: Publish TFX CLI to npm

29 changes: 28 additions & 1 deletion app/lib/jsonvalidate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var fs = require("fs");
import * as path from 'path';
var check = require("validator");
var trace = require("./trace");

Expand Down Expand Up @@ -92,5 +93,31 @@ export function validateTask(taskPath: string, taskData: any): string[] {
if (!taskData.instanceNameFormat) {
issues.push(vn + ": instanceNameFormat is required");
}
return issues;

if (taskData.execution) {
const supportedRunners = ["Node", "Node10", "Node16", "Node20_1", "PowerShell", "PowerShell3", "Process"]

for (var runner in taskData.execution) {
if (supportedRunners.indexOf(runner) > -1) {
var runnerData = taskData.execution[runner];
if (!runnerData.target) {
issues.push(vn + ": execution." + runner + ".target is required");
} else {
const target = runnerData.target.replace(/\$\(\s*currentdirectory\s*\)/i, ".");

// target contains a variable
if (target.match(/\$\([^)]+\)/)) {
continue;
}

// check if the target file exists
if (!fs.existsSync(path.join(path.dirname(taskPath), target))) {
issues.push(vn + ": execution target for " + runner + " references file that does not exist: " + target);
}
}
}
}

return (issues.length > 0) ? [taskPath, ...issues] : [];
}
}