Azure Çekme İsteği / Azure Devops - "' + ' işlecini izleyen bir değer ifadesi sağlamanız gerekir."

0

Soru

Şu anda bu yaml dosyasını çalıştırıyorum:

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

Bunun iyi çalıştığından emin olmak için, yeni pr'den gelen yorumlarda aşağıdaki komutu iletmem gerekecek:

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

Bunu yaparak, aşağıdaki soruna sahip olacağım:

"'+'işlecini izleyen bir değer ifadesi sağlamanız gerekir."

Bu tür hata mesajlarını önlemek için başka neler yapabileceğimi bilen var mı?

1

En iyi cevabı

-2

PR açıklamamın içine aşağıdaki şablonu ekleyerek sorunumu çözdüm:

Tanım Bla Bla repo'ya katkılarınız için teşekkür ederiz. Bu pr'yi göndermeden önce lütfen emin olun:

  • [] Düzelt
  • [] Özellik
  • [] Büyük

Not: Farklı terminolojiye sahip olmak istiyorsanız, regex bölümünü değiştirmeniz gerekir. Örnek olarak:

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

Aynı zamanda, eşleşeceğinden emin olmak için Çekme İsteğinin içine eklediğiniz onay kutularının içinde bir değişiklik yapmanız gerekecektir.

Şimdi, komut dosyası çalışıyor. Projenize anlamsal sürüm oluşturma eklemek için bir kılavuz görmek isterseniz, kılavuzun oluşturucu bağlantısına bakmanız gerekir: https://www.moderndata.ai/2021/10/automatic-semantic-versioning-in-azure-devops-with-release-notes/. Oluşturduğum ana soruna bakın - $(Sistem.PullRequest.SourceBranch) bulunamadı.

2021-11-24 20:07:00

Orijinal göreviniz bir git tamamlama hatasıdır. Cevabınız sorunu nasıl çözüyor?
John Hanley

SemVer için git tamamlama mesajı ekle Powershell komut dosyaları, Çekme İsteğimin bir Düzeltme, Özellik veya Büyük olup olmayacağını bildirebileceğimden emin olmak için onay kutularını alacak bazı regex'lere sahiptir. Yukarıdaki formu PR Yorumlarına ekleyerek sorunu çözdük
Hvaandres

Bu benim cevabım, yorumlarım için şablonu pr'mın içine ekledim ve ihtiyacım olan seçeneği seçtim. Komut dosyasını okuyun ve regex'in sizden onay kutuları istediğini göreceksiniz ve bunları PR yorumlarınızın içine eklerseniz, bu komut dosyasıyla oynayabileceksiniz. Senaryonun kendisinde yanlış bir şey yok ve başlangıçta anlamadım, ama şimdi çözdüm ve takip ettiğim kılavuzu paylaşıyorum
Hvaandres

Diğer dillerde

Bu sayfa diğer dillerde

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