dxatscale / sfpowerscripts

A build system for modular development in Salesforce
https://dxatscale.io
MIT License
211 stars 94 forks source link

sfpowerscript-deploysourcetoorg-task: "path should be a path.relative()d string" error #176

Closed extravio closed 4 years ago

extravio commented 4 years ago

Hi, I'm trying to execute the sfpowerscript-deploysourcetoorg-task in a release pipeline in yaml. (It works fine in Azure pipeline classic).

The artifact is downloaded in the default directory: $(System.ArtifactsDirectory) (/home/vsts/work/1/a) and I set the project_directory parameter of the task to: $(System.ArtifactsDirectory)/$(ARTIFACT_NAME)/source

I get the following error: path should be a path.relative()d string, but got "../a//source/force-app/main"

Is this a bug or am I missing something?

Here's an extract of my pipeline yml file:

variables:
  - group: Dreamhouse
  - name: ARTIFACT_NAME
    value: $(PACKAGE_NAME)_sfpowerscripts_artifact
  - name: ARTIFACT_DIRECTORY
    value: '$(System.ArtifactsDirectory)/$(ARTIFACT_NAME)/source'

stages:
- stage: Packaging
  jobs:
  - job: BuildFullSourcePackage
    displayName: Source Package build
    condition: contains(variables['Build.SourceBranch'], 'refs/heads/feature')
    steps:
    - script: sudo npm install sfdx-cli --global
      displayName: 'Install sfdx'
    - task: AzlamSalam.sfpowerscripts.sfpwowerscript-incrementversionnumber-task.sfpwowerscript-incrementversionnumber-task@9
      displayName: 'Increments the BuildNumber version number '
      name: incBuildNumber
      inputs:
        commit_changes: true
        # pushchanges: true
        versionControlProvider: azureRepo
    - task: AzlamSalam.sfpowerscripts.sfpwowerscripts-createsourcepackage-task.sfpwowerscripts-createsourcepackage-task@12
      displayName: 'Creates a new version of source based repo for force-di'
      inputs:
        package: $(PACKAGE_NAME)
        version_number: $(incBuildNumber.sfpowerscripts_incremented_project_version)

- stage: Validation
  jobs:
  - job: ValidationUAT
    displayName: Validate the deployment on UAT
    steps:
    - checkout: none
    - task: DownloadBuildArtifacts@0
      inputs:
        artifactName: '$(ARTIFACT_NAME)'
    # - task: AzlamSalam.sfpowerscripts.sfpwowerscript-checkoutprojectfromartifact-task.sfpwowerscript-checkoutprojectfromartifact-task@14
    #   displayName: 'Checkout  from associated build pipeline'
    #   inputs:
    #     versionControlProvider: azureRepo
    #     package: '$(PACKAGE_NAME)'
    - task: AzlamSalam.sfpowerscripts.sfpwowerscript-installsfdx-task.sfpwowerscript-installsfdx-task@7
      displayName: 'Install SFDX'
    - task: AzlamSalam.sfpowerscripts.sfpwowerscript-authenticateorg-task.sfpwowerscript-authenticateorg-task@9
      displayName: 'Authenticate JWT'
      inputs:
        method: JWT
        jwt_key_file: server.key
        username: $(SF_USERNAME)
        alias: RAT
        isdevhub: true
        clientid: $(SF_CONSUMER_KEY)
    - task: AzlamSalam.sfpowerscripts.sfpowerscript-deploysourcetoorg-task.sfpowerscript-deploysourcetoorg-task@10
      displayName: 'Deploy source'
      inputs:
        target_org: RAT
        project_directory: '$(ARTIFACT_DIRECTORY)'
        source_directory: 'force-app'
        checkonly: true
azlam-abdulsalam commented 4 years ago

@extravio Thanks for reaching out! Looks like the latest release which had lot of artifact refactoring broke the YAML compat. We will be addressing it early next week. At the moment, we have a shortcoming, all our test suites for the release side of things are based on classic, hence the miss.

While we fix this, here is the workaround in YAML. Please use the of tasks in your org.

Also note you need to use download the artifact using the download step in the deployment stage


stages:
#Build Source Package 
- stage: BuildSourcePackage
  displayName: 'Build a source package and test multiple deployments'
  dependsOn: []
  condition: ''
  jobs:
  - job: SourcePackageBuild
    strategy:
     matrix:
      ubuntu::
        image: 'ubuntu-latest' 
    pool:
      vmImage: $(image)  
    displayName: Source Package build  for force-di
    steps:
    - task: sfpwowerscript-installsfdx-task@7
      displayName: Install SFDX
    - task: sfpwowerscripts-createsourcepackage-task@13
      displayName: Create a new version of Source Package
      name: createpackage
      inputs:
        package: force-di
        version_number: 1.0.0.$(Build.BuildNumber)

#Deploy Source Package      
- stage: DeploySourcePackage
  displayName: 'Deploy Source Package'
  dependsOn: BuildSourcePackage
  condition: ''
  jobs:
  - job: DeploySourcePackage
    strategy:
     matrix:
      ubuntu::
        image: 'ubuntu-latest' 
    pool:
      vmImage: $(image)  
    displayName: Install the Source Package to an org
    steps:

    - download: current

    - task: sfpwowerscript-installsfdx-task@7
      displayName: Install SFDX

    - task: sfpwowerscript-authenticateorg-task@9
      displayName: Authenticate Org
      inputs:
        method: JWT
        jwt_key_file: server.key
        username: $(username)
        alias: HubOrg
        isdevhub: true
        clientid: $(clientid)

    - task: sfpwowerscript-managescratchorg-task@8
      displayName: Create Scratch Org
      inputs:
        action: Create
        config_file_path: config/project-scratch-def.json
        alias: scratchorg
        devhub_alias: HubOrg
        maintainorg: delete

    - task: sfpowerscript-deploysourcetoorg-task@10
      displayName: Deploy Source Directory to the org
      inputs:
        target_org: 'scratchorg'
        source_directory: 'force-di'
        checkonly: true
        ignorewarnings: true
        ignoreerror: true
        wait_time: '20'
        testlevel: 'NoTestRun'
        isToBreakBuildIfEmpty: true
azlam-abdulsalam commented 4 years ago

@extravio We have released a patch to this bug. Please let us know if it works.

extravio commented 4 years ago

Many thanks for the quick turnaround. It works perfectly! ^ @azlam-abdulsalam