Zapytanie na rozciąganie Azure w | Azure Devops - "należy podać wyrażenie wartości po operatora"+"".

0

Pytanie

Obecnie uruchamiam ten plik yaml:

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

Aby upewnić się, że to działa dobrze, muszę przekazać następujące polecenie w komentarzach do nowego PR:

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

Czyniąc to, u mnie wystąpił następujący problem:

"Musisz podać wyrażenie wartości po operatora"+"".

Czy ktoś wie co jeszcze mogę zrobić, aby zapobiec komunikaty o błędach tego typu?

1

Najlepsza odpowiedź

-2

Postanowiłem swój problem, dodając następujący wzór w swoje opis PR:

Opis Dziękuję ci za twój wkład w repo Bla-Bla. Przed wysłaniem tego PR, proszę, upewnij się, że:

  • [ ] Naprawić
  • [ ] Funkcja
  • [ ] Duże

Uwaga: Jeśli chcesz użyć innej terminologii, trzeba zmienić część wyrażenia regularnego. Jako przykład:

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

W tym samym czasie trzeba będzie wprowadzić zmiany do wyboru, które zostały dodane w poprosi o wyjęcie, aby upewnić się, że będzie pasować.

Teraz skrypt działa. Jeśli chcesz zobaczyć instrukcja dodawania semantycznej kontroli wersji w swój projekt, trzeba będzie zobaczyć link twórcy podręcznika: https://www.moderndata.ai/2021/10/automatic-semantic-versioning-in-azure-devops-with-release-notes/. Spójrz na główny problem, który stworzyłem - $(System.Wyciągnij wniosek.Źródło) nie znaleziono.

2021-11-24 20:07:00

Swoje pierwsze zadanie-to błąd git-zatwierdzenia. Jak twoja odpowiedź rozwiązuje problem?
John Hanley

Dodaj komunikat w sprawie zatwierdzenia git dla skryptów Powershell SemVer, w których istnieją pewne wyrażenie regularne, które zainstaluje pola wyboru, aby upewnić się, że mogę ogłosić, czy mój wniosek na wyjmowanie poprawki, funkcji lub Dużą. Dodanie formularza powyżej w PR-komentarze, możesz rozwiązać problem
Hvaandres

Oto moja odpowiedź, dodałem szablon do swoich komentarzy na swój PR i wybrał odpowiednią mi opcja. Przeczytaj scenariusz, a zobaczysz, że wyrażenie regularne prosi o zaznaczenie, a jeśli dodać je do swoich PR-komentarze, można się pobawić z tym scenariuszem. W samym skrypcie nie ma nic złego, a ja nie rozumiem tego na początku, ale teraz postanowiłem podzielić się kierunkiem, który szedł
Hvaandres

W innych językach

Ta strona jest w innych językach

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