Skip to content

Shell expansion inside Execute task #7

@gsreynolds

Description

@gsreynolds

A Policy Build pipeline (using chef export -a) will give a policy archive with a name based on PolicyName-RevisionId.tgz. Publishing this as a build artifact leads to not knowing exactly what the policy archive is named in the artifact directory.
Screenshot 2020-09-18 at 12 35 07

Previously I would do the following and (ab)use shell expansion to get the name of the policy archive (the only file in that directory):

steps:
- script: 'chef push-archive development $(Release.PrimaryArtifactSourceAlias)/$(Build.DefinitionName)/*.tgz'

It appears that shell expansion doesn't work in the execute component task just now. This is my workaround:

steps:
- script: 'mv $(Release.PrimaryArtifactSourceAlias)/$(Build.DefinitionName)/*.tgz $(Release.PrimaryArtifactSourceAlias)/$(Build.DefinitionName)/$(Build.DefinitionName).tgz'
  displayName: 'Rename Policy Archive'
- task: chef-software.chef-preview.execute.component-preview@2
  displayName: 'chef push-archive development'
  inputs:
    component: chef
    arguments: 'push-archive development $(Release.PrimaryArtifactSourceAlias)/$(Build.DefinitionName)/$(Build.DefinitionName).tgz'

A couple other options would just be to rename the build artifact in the policy build pipeline before it's published, or read the policy lock JSON and pass the revision ID between pipelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions