Cloud customer?
Start for Free>
Upgrade in MyJFrog >
What's New in Cloud >







You are viewing an old version of this page. View thecurrent version.

Compare with CurrentView Page History

« PreviousVersion 17Current »

Overview

ThePowerShellstep typeis a generic type that enables executing PowerShell commands. PowerShell steps can only run on Windows node pools and are similar to the Bash step on other node pools. As a general-purpose step that can execute any action that can be scripted, even with tools and services that haven't been integrated with JFrog Pipelines, it can be used to perform actions where complete control is required.


All native steps running in a Windows node pool derive from the PowerShell step. This means that all steps share the same base set of tags from PowerShell, while native steps have their own additional tags as well that support the step's particular function. So it's important to be familiar with the PowerShell step definition when running steps on Windows, since it's the core of the definition of all other steps.

Usage


PowerShell
管道:名称:<字符串>步骤:-名称:<字符串> type: PowerShell configuration: affinityGroup: bldGroup priority: <[0-10000]> timeoutSeconds:  nodePool:  chronological:  environmentVariables: env1:  env2:  env3: default:  description:  values:  allowCustom:  integrations: - name:  inputSteps: - name:  inputResources: - name:  trigger:  # default true branch:  # see description of defaults below outputResources: - name:  branch:  # see description of defaults below runtime: type:  image: auto: language: versions: custom: name: tag: options: registry:  # optional integration for a private registry sourceRepository:  # required if registry is Artifactory. e.g. docker-local region: # required if registry is AWS. e.g. us-east-1 autoPull:  # default true; pulls image before run execution: onStart: - echo "Preparing for work..." onExecute: - echo "executing task command 1" - echo "executing task command 2" onSuccess: - echo "Job well done!" onFailure: - echo "uh oh, something went wrong" onComplete: #always - echo "Cleaning up some stuff"
Page Contents

Tags

name

Analphanumericstring (underscores are permitted) that identifies the step. The name should be chosen to accurately describewhat the step does, e.g.prov_test_envto represent a job that provisions a test environment. Names of steps must be unique within a pipeline.

type

Must bePowerShellfor this step type.

configuration

Specifiesalloptional configuration selections for the step's execution environment.

Tag

Description of usage

Required/Optional
affinityGroup Label that controls affinity to a Node. All the steps with the same affinityGroup will be executed on the same node. This will allow sharing state between the steps. An example is having the same affinityGroup for DockerBuild and DockerPush steps in a Pipeline so that Image being built in the DockerBuild step can be used to published in the DockerPush step Optional
priority

Controls the priority of a step when there are parallel steps in a pipeline or multiple pipelines executing. It determines which step will run first across all steps that could run if there were no constraints on the number of steps running. Steps with a lower number will run before steps with higher numbers. For example, priority 10 will run before priority 100. The default priority is 9999.

Priority does not apply to steps that are still waiting for an input to complete or configured to run in a node pool with no available nodes. Also, if there are two steps ready to run and only one available node, the one with the lower priority number runs first, regardless of which pipeline each step belongs to.

Optional
timeoutSeconds Time limit, in the number of seconds, for the step to complete. If the step does not complete in the given time limit, the step will be forced to a completion state of failed. Optional
nodePool Assigns the node pool on which the step executes. If node pool isn't specified, a step will execute on the default node pool.See hereto learn more about node pools. Optional
chronological

Specifies that the step must execute in chronological order, to ensure receipt of all state updates from preceding steps.
A step withchronological: truewillonly execute when that step is complete in allpreviously triggered runs.

Optional
environmentVariables Assigns any environment variables and their values in key:value format. All environment variables assigned within a step definition are active only for the scope of the execution of that step. Variables will be available in global scope and in theenvdrive.

If the following variables are set, they will be used:

  • JFROG_CLI_BUILD_NAME: If set, the pipeline uses this value instead of the default pipeline name for the build info collected.
  • JFROG_CLI_BUILD_NUMBER: If set, the pipeline uses this value instead of the default run number for the build info collected.
  • USE_LOCAL_JFROG_CLI: Ifset astrue, the local JFrog CLI on the host or in the image (depending onruntimeconfiguration) is used instead of the version packaged with JFrog Pipelines. This is not recommended and native steps may not be able to run with the local JFrog CLI version.
Optional
integrations A collection of integrations that will be used by this step. Integrations can be used directly in step without a resource. Optional
inputSteps n的集合amed steps whose completion will trigger execution of this step. Optional
inputResources

n的集合amed resources that will be used by this step as inputs.

By default,这些命名资源的变化2022世界杯阿根廷预选赛赛程will trigger execution of this step. This can be changed by declaringtriggerto befalse.

Abranchis only required when using a resource from another branch of a multi-branch source. By default, the resource from a single-branch source or from the same branch of a multi-branch pipeline is used. To use a multi-branch resource in a single-branch pipeline or another branch in a multi-branch pipeline,branchshould be used to specify the branch to which the resource belongs.

Optional
outputResources

n的集合amed resources that will be generated or changed by this step.

Abranchis only required for resources from another branch of a multi-branch source. By default, the resource from a single-branch source or from the same branch of a multi-branch pipeline is assumed. To update a multi-branch resource in a single-branch pipeline or another branch in a multi-branch pipeline,branchshould be used to specify the branch to which the resource belongs.

Optional
runtime Specifies the runtime for the execution node. Optional

execution

Declare sets of shell command sequences to perform for different execution phases:

Tag Description of usage Required/Optional
onStart Commands to execute in advance ofonExecute Optional
onExecute Main commands to execute for the step Optional
onSuccess Commands to execute on successful completion ofonExecute Optional
onFailure Commands to execute on failed completion ofonExecute Optional
onComplete Commands to execute on any completion ofonExecute Optional

Example

This is anexampleof how to use the PowerShell step to perform a build activity.

PowerShell step to build
- name: build type: PowerShell configuration: nodePool: my_windows_node_pool environmentVariables: env1: value1 env2: default: value2 description: Example Variable values: - value2 - value3 allowCustom: false runtime: type: image image: auto: language: node versions: - "10.18" inputResources: - name: src integrations: - name: mySlack execution: onExecute: - Push-Location $res_src_resourcePath - npm install - New-Item testresults -Type Directory - New-Item codecoverage -Type Directory - .\node_modules\.bin\mocha --recursive "tests/**/*.spec.js" -R mocha-junit-reporter --reporter-options mochaFile=testresults/testresults.xml - .\node_modules\.bin\istanbul --include-all-sources cover -root "routes" node_modules/mocha/bin/_mocha -- -R spec-xunit-file --recursive "tests/**/*.spec.js" - .\node_modules\.bin\istanbul report cobertura --dir codecoverage - save_tests testresults/testresults.xml onSuccess: - send_notification mySlack "build completed"
  • No labels
Copyright © 2023 JFrog Ltd.