Azure devops - server-side git hooks

后端 未结 3 1783
情话喂你
情话喂你 2021-01-21 01:53

How can we implement server-side hooks, or any similar solution, to restrict git push into git server?

For example, we want to disable push of commits containing *.class

3条回答
  •  再見小時候
    2021-01-21 02:09

    What I do is using build option together with policies in Azure DevOps. This is my azure-pipelines.yml file:

    ---
    trigger:
      branches:
        exclude:
          - '*'
    
    pool:
      vmImage: 'ubuntu-latest'
    
    steps:
      - script: sudo apt-get install python3-pip
        displayName: 'Install Python PIP'
    
      - script: sudo apt-get install python3-setuptools
        condition: succeeded()
        displayName: Install Python SetupTools
    
      - script: sudo pip3 install -r requirements.txt
        condition: succeeded()
        displayName: Install Python PIP Packages
    
      - task: PythonScript@0
        inputs:
          scriptSource: filePath
          scriptPath: hooks/lint_checker.py
          pythonInterpreter: python3
        condition: succeeded()
        displayName: Lint Checker
    

提交回复
热议问题