Search code examples
azure-devopsazure-pipelines

Not able to create a release workitem using CreateWorkItem@2 task


I am trying to create a release work item using azure pipeline task "CreateWorkItem@2" but the pipeline is failing due to TF401320: Rule Error for field Description error.

Task Code"

- task: CreateWorkItem@2
  inputs:
    teamProject: $(project)
    workItemType: 'Release'
    title: $(title)
    assignedTo: '$(Build.RequestedFor)'
    areaPath: $(areaPath)
    iterationPath: ${{ parameters.IterationPath }}
    fieldMappings: '[Description=This has been bulk created by CWI task, 
                     Transition Management Approved=No, Not required.]'
    authType: 'internal'

Wants create a release work item using

CreateWorkItem@2

Solution

  • TF401320: Rule Error for field Description error.

    Based on your YAML definition, the cause of the issue is that the Description field value not input the correct value when creating work item.

    To solve this issue, you need to change the fieldMappings field of the CreateWorkItem@2 with the following format:

    fieldMappings: |
     field1=value1
     field2=value2
    

    Task example:

    - task: CreateWorkItem@2
      inputs:
        teamProject: $(project)
        workItemType: 'Release'
        title: $(title)
        assignedTo: '$(Build.RequestedFor)'
        areaPath: $(areaPath)
        iterationPath: ${{ parameters.IterationPath }}
        fieldMappings: |
         Description=This has been bulk created by CWI task
         Transition Management Approved=No, Not required.
        authType: 'internal'
    

    In this case, the Description and Transition Management Approved field will be input the correct value when creating work items.