Azure Vytiahnuť Žiadosť | Azure Devops - "musíte zadať hodnotu výrazu nasledujúce operátor"+"."

0

Otázka

Ja som v súčasnej dobe beží tento yaml súbor:

trigger:
- none
## notes 
pool:
  vmImage: ubuntu-latest

## Job to calculate semantic version
jobs:
  - job: CalculateVersion
    displayName: Semantic versioning
    
    steps:
      # Checkout with persist credentials
      - checkout: self
        persistCredentials: true

      # Install GitVersion
      - task: gitversion/setup@0
        displayName: Install GitVersion
        inputs:
          versionSpec: '5.x'

      # Retrieve Pull Request Description
      - task: PullRequestDescription@0
        name: RetrievePullRequestDescription
        displayName: Retrieve Pull Request description
        inputs:
          action: 'view'
          outputVariable: 'PullRequest.DescriptionContent'
          isOutput: true
          stripIdentifiers: false

      # Add git commit message that will be picked up by GitVersion ("+semver: patch/minor/major")
      # Depending on the Pull Request description, where the developer has marked the type of change
      - task: PowerShell@2
        displayName: Add git commit message for SemVer
        inputs:
          targetType: inline
          script: |
            Write-Host "Configuring git author info.." -ForegroundColor Cyan
          
            git config user.email "[email protected]"
            git config user.name "alan.haro"
            Write-Host "Doing git checkout..." -ForegroundColor Cyan
            git checkout -b $("$(System.PullRequest.SourceBranch)".replace('refs/heads/creating-git-tags', ''))
            Write-Host "Checking Pull Request description..." -ForegroundColor Cyan
            $PRdesc = "$(RetrievePullRequestDescription.PullRequest.DescriptionContent)"
            if ($PRdesc -match '(\[x\] \bFix\b)') {
              Write-Host "Adding git (empty) commit message to mark this branch as a 'patch' SemVer increment." -ForegroundColor Cyan
              git commit -a -m "+semver: patch [skip azurepipelines]" --allow-empty
            } elseif ($PRdesc -match '(\[x\] \bFeature\b)') {
              Write-Host "Adding git (empty) commit message to mark this branch as a 'minor' SemVer increment." -ForegroundColor Cyan
              git commit -a -m "+semver: minor [skip azurepipelines]" --allow-empty
            } elseif ($PRdesc -match '(\[x\] \bBig\b)') {
              Write-Host "Adding git (empty) commit message to mark this branch as a 'major' SemVer increment." -ForegroundColor Cyan
              git commit -a -m "+semver: major [skip azurepipelines]" --allow-empty
            } else {
              Write-Host "##vso[task.LogIssue type=error;]Please select the type of change in the Pull Request description, and Re-queue the validation." -ForegroundColor Cyan
              $PRdesc
              exit 1
            }
            Write-Host "Doing git push.." -ForegroundColor Cyan
            git push --set-upstream origin $("$(System.PullRequest.SourceBranch)".replace('refs/heads/', ''))
            Write-Host "Done." -ForegroundColor Cyan
          
      # Determine the semantic version & test test
      - task: gitversion/execute@0
        displayName: Determine SemVer

Uistite sa, to beží dobre, budem mať na prešiel nasledujúci príkaz v komentároch z nových PR:

git commit -a -m "+'semver: minor [skip azurepipelines]'" --allow-empty

Týmto spôsobom budem mať nasledujúci problém:

"Musíte zadať hodnotu výrazu nasledujúce operátor"+"."

Má niekto vie, čo ešte môžem urobiť pre prevenciu tohto typu chybové hlásenia?

1

Najlepšiu odpoveď

-2

Som vyriešil môj problém pridaním tieto šablóny vo vnútri môjho PR popis:

Popis Ďakujeme vám za váš príspevok k Bla Bla repo obchody. Pred odoslaním tohto PR, uistite sa, prosím:

  • [ ] Fix
  • [ ] Funkcia
  • [ ] Veľká

Poznámka: Ak by ste chceli mať inú terminológiu, budete musieť zmeniť regulárny výraz časť. Ako príklad:

 if ($PRdesc -match '(\[x\] \**bFix**\b)')

V rovnakom čase, budete musieť urobiť zmeny vo vnútri políčok, ktoré ste pridali vnútri Potiahnite Žiadosť uistite sa, že to bude zápas.

Teraz, skript pracuje. Ak by ste chceli vidieť príručka ak chcete pridať sémantické verzií vášho projektu, budete musieť pozrieť na sprievodcu tvorca odkaz: https://www.moderndata.ai/2021/10/automatic-semantic-versioning-in-azure-devops-with-release-notes/. Pozrite sa na hlavný problém, ktorý som vytvoril - $(Systém.PullRequest.SourceBranch) č nájsť.

2021-11-24 20:07:00

Vaše pôvodné quest je git commit chyba. Ako sa vaša odpoveď vyriešiť problém?
John Hanley

Pridať git commit správy pre SemVer Powershell skripty majú niektoré regulárny výraz, ktorý sa uskutoční v mieste políčka, aby som sa budú môcť vyhlásiť, ak môj Vytiahnuť Žiadosť bude Opraviť, Funkciu alebo Veľký. Pridaním formulára hore v PR-Komentáre vyriešil problém
Hvaandres

To je moja odpoveď, som pridal šablónu pre moje komentáre vnútri môjho PR, a vybrať možnosť, že potrebujem. Prečítajte si skript, a uvidíte, že regulárny výraz je so žiadosťou o políčka, a ak pridáte tých, vnútri vo vašom PR komentáre, budete môcť hrať s týmto skriptom. Skript sám nemá nič zlé, a nerozumel som to na začiatku, ale teraz som vyriešil a ja som zdieľanie sprievodca, ktorý som sledoval
Hvaandres

V iných jazykoch

Táto stránka je v iných jazykoch

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................