Home > Software engineering >  Azure DevOps Pipeline: AWS CLI Task, How to reference predefined variables
Azure DevOps Pipeline: AWS CLI Task, How to reference predefined variables

Time:09-23

I am using the AWS CLI task to deploy a Lambda layer. The build pipeline upstream looks like this:

enter image description here

It zips up the code, publishes the artifact and then downloads that artifact.

Now in the release pipeline I'm deploying that artifact via an AWS CLI command. The release pipeline looks like this:

enter image description here

I'm trying to figure out a way to dynamically get the current working directory so I don't need to hardcode it. In the options and parameters section you can see I'm trying to use $(Pipeline.Workspace) but it doesn't resolve correctly.

Is this possible?

CodePudding user response:

Correct me if I am wrong, but I looks like you are running this in Azure Release? Not Pipelines?

If that is the case I think the variable you are looking for is $(Release.PrimaryArtifactSourceAlias) .

See the section of the document that talks about release specific variables: https://docs.microsoft.com/en-us/azure/devops/pipelines/release/variables?view=azure-devops&tabs=batch#default-variables---release

CodePudding user response:

Yes. This is completely achievable.

From your screenshot, you are using the Release Pipeline to deploy the Artifacts.

In your situation, the $(Pipeline.Workspace) can only be used in Build Pipeline.

Refer to this doc: Classic release and artifacts variables

You can use the variable: $(System.ArtifactsDirectory) or $(System.DefaultWorkingDirectory)

The directory to which artifacts are downloaded during deployment of a release. The directory is cleared before every deployment if it requires artifacts to be downloaded to the agent. Same as Agent.ReleaseDirectory and System.DefaultWorkingDirectory.

  • Related