Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml deployment job download path issue #566

Open
rodchenkov opened this issue May 22, 2022 · 2 comments
Open

Yaml deployment job download path issue #566

rodchenkov opened this issue May 22, 2022 · 2 comments
Assignees
Labels
Area: Yaml question Further information is requested

Comments

@rodchenkov
Copy link

When using deployment job in yaml the artifacts from CI pipeline downloaded to '/home/vsts/work/1/ci/...'
How to get this path as variable in pipeline?

Starting: Download Artifact

Task : Download build artifacts
Description : Download files that were saved as artifacts of a completed build
Version : 0.200.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/download-build-artifacts

Downloading artifacts for build: 4724
Downloading items from container resource #/21772323/project
Downloading artifact project from: https://dev.azure.com/aurochses//_apis/resources/Containers/21772323?itemPath=project&isShallow=true&api-version=4.1-preview.4
Downloading project/3rdpartylicenses.txt to /home/vsts/work/1/ci/project/3rdpartylicenses.txt
Downloaded project/3rdpartylicenses.txt to /home/vsts/work/1/ci/project/3rdpartylicenses.txt
Downloading project/favicon.ico to /home/vsts/work/1/ci/project/favicon.ico
Downloaded project/favicon.ico to /home/vsts/work/1/ci/project/favicon.ico
Downloading project/index.html to /home/vsts/work/1/ci/project/index.html
Downloaded project/index.html to /home/vsts/work/1/ci/project/index.html
Downloading project/main.06b493153b659fa5.js to /home/vsts/work/1/ci/project/main.06b493153b659fa5.js
Downloaded project/main.06b493153b659fa5.js to /home/vsts/work/1/ci/project/main.06b493153b659fa5.js
Downloading project/polyfills.f04764812ed2518a.js to /home/vsts/work/1/ci/project/polyfills.f04764812ed2518a.js
Downloaded project/polyfills.f04764812ed2518a.js to /home/vsts/work/1/ci/project/polyfills.f04764812ed2518a.js
Downloading project/runtime.231e96734c9fdc57.js to /home/vsts/work/1/ci/project/runtime.231e96734c9fdc57.js
Downloaded project/runtime.231e96734c9fdc57.js to /home/vsts/work/1/ci/project/runtime.231e96734c9fdc57.js
Downloading project/styles.ef46db3751d8e999.css to /home/vsts/work/1/ci/project/styles.ef46db3751d8e999.css
Downloaded project/styles.ef46db3751d8e999.css to /home/vsts/work/1/ci/project/styles.ef46db3751d8e999.css
Total Files: 7, Processed: 7, Skipped: 0, Failed: 0, Download time: 1.009 secs, Download size: 79505Bytes
Successfully downloaded artifacts to /home/vsts/work/1/ci
Finishing: Download Artifact

yaml example

stages:

  • stage: Dev
    displayName: 'Dev'
    jobs:
    • deployment: Deploy
      displayName: 'Deploy'
      pool:
      vmImage: 'ubuntu-latest'
      environment: 'Dev'
      strategy:
      runOnce:
      deploy:
      steps:
      - task: AzureStaticWebApp@0
      inputs:
      workingDirectory: '$(Pipeline.Workspace)/ci'
      app_location: '/project'
      skip_app_build: true
      skip_api_build: true
      azure_static_web_apps_api_token: '$(devMainStaticWebAppApiKey)'

Thank you

@KonstantinTyukalov
Copy link

KonstantinTyukalov commented May 30, 2022

Hi @rodchenkov you can define pipeline variables by this article: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch

Your case will be like:

variables:
  CI_DIR: $(Pipeline.Workspace)/ci  # here you define pipeline variable

stages:
- stage: Dev
  displayName: 'Dev'
  jobs:
    deployment: Deploy
    displayName: 'Deploy'
    pool:
    vmImage: 'ubuntu-latest'
    environment: 'Dev'
    strategy:
    runOnce:
    deploy:
    steps:
    - task: AzureStaticWebApp@0
      inputs:
      workingDirectory: $(CI_DIR) # here you use it
      app_location: '/project'
      skip_app_build: true
      skip_api_build: true
      azure_static_web_apps_api_token: '$(devMainStaticWebAppApiKey)'

Is this solution fits your case?

@KonstantinTyukalov KonstantinTyukalov self-assigned this May 30, 2022
@KonstantinTyukalov KonstantinTyukalov added question Further information is requested and removed triage labels May 30, 2022
@rodchenkov
Copy link
Author

Hi @KonstantinTyukalov and thanks for your help.
Variable is nice option, but looks like what I really need is to understand how to get name of pipeline from witch we are getting artifacts.
What I found is that name of pipeline is same as name of folder to witch our CD downloads artifacts.
As you can see in code below in resources we have pipelines with one pipeline named ci
Later during download step we can see that subfolder for artifacts with same ci name created so we are getting this path '/home/vsts/work/1/ci/...'

Do we have any options to get name of pipeline or shall I just use variable with manual setup as you mentioned before?

`
trigger: none

resources:
pipelines:

  • pipeline: ci
    source: CI_Website.Main
    trigger:
    branches:
    include:
    - refs/heads/main
    repositories:
  • repository: templates
    type: github
    endpoint: 'GitHub.Pipeline.Templates'
    name: 'Org1/AzureDevOps.Pipeline.Templates'
    ref: 'refs/tags/latest'
  • repository: other-templates
    type: git
    name: 'Org2/AzureDevOps.Pipeline.Templates'

variables:

  • group: StaticWebApps

stages:

  • stage: Dev
    displayName: 'Dev'
    jobs:
    • template: 'Angular/deploy-to-azure-static-web-app.yml@other-templates'
      parameters:
      environmentName: 'Dev'
      staticWebAppApiKey: $(devMainStaticWebAppApiKey)
      `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Yaml question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants