Artifact dependencies (destination) using Bamboo YAML specs

Viewed 1604

I'm trying to set up the Bamboo build plan configuration using Bamboo YAML specs (.yml file below). In the last stage (Create deployment artifacts) I want to use the shared artifacts from the previous stage. By specifying the artifacts of the jobs as "shared: true" I can use them in the second stage. However, they are in the same destination folder. Using the UI this can be easily edited.

Artifact dependencies

But how can I specify the destination folder of the two artifacts in the Bamboo YAML specs, e.g. from "Root of working directory" to "./app" and "./wwwroot", respectively?

---
version: 2
plan:
  project-key: COCKPIT
  key: BE
  name: Cockpit - Continuous Build - Windows 
stages:
  - Build Stage:
    - Build Backend
    - Build Frontend
  - Build Artifact:
    - Create Deployment Artifact

Build Backend:
  requirements:
    - Visual Studio Build Tools (32-bit)
  tasks:
    - checkout:
        repository: cockpit_backend
        path: 'cockpit_backend'
        force-clean-build: false
    - script:
      - dotnet publish .\cockpit_backend\src\Cockpit.WebApi\ --configuration Release

  artifacts:
    -
      name: BackendBuild
      location: cockpit_backend/src/Cockpit.WebApi/bin/Release/netcoreapp3.1/publish
      pattern: '**/*.*'
      required: true
      shared: true

Build Frontend:
  requirements:
    - os_linux
  tasks:
    - checkout:
        repository: 'Cockpit / cockpit_frontend'
        path: 'cockpit_frontend'
        force-clean-build: false
    - script:
      - cd cockpit_frontend
      - npm install
    - script:
      - cd cockpit_frontend
      - npm run build-prod
  docker: 
    image: node:alpine
  artifacts:
    -
      name: FrontendBuild
      location: cockpit_frontend/dist
      pattern: '**/*.*'
      required: true
      shared: true

Create Deployment Artifact:
  requirements:
    - os_windows
  tasks:
    - script:
        interpreter: powershell
        scripts:
          - $buildDir = "Cockpit"
          - $dest = "Cockpit_${bamboo.buildNumber}.zip"
          - Add-Type -assembly "system.io.compression.filesystem"
          - '[io.compression.zipfile]::CreateFromDirectory($buildDir, $dest)'
  artifacts:
    -
      name: Completebuild
      pattern: 'Cockpit_${bamboo.buildNumber}.zip'
      required: true
1 Answers

YAML specs doesn't support artifact dependency management and you need to have script task at "Create Deployment Artifact" job to put them into separate folders from root before compressing

Related