I have written a scanning tool in python to be run on PR for all our repos, but I am not sure what the best approach is to generalize the usage of this code with all our individual pipelines. Any pointers would be greatly appreciated!
I have considered using the "Python Script" task in the pipeline, but it seems to be tailored to scripts within the same repo.
I have considered using an exe but am unsure if this will be too rigid in terms of future changes to the scanning tool itself.
If you want to use "Python Script" task to run python script file in another repo within the same organization, maybe you could try to add the task as a part of a template then run the template in your current repo pipeline:
Please see whether the following steps could do some help:
1.For example, here I have a simplest python file called 'python2' in repo 'store python file'
2.Create a template with task Python Script and the file path directs to 'python2'
steps:
- checkout: template # the 'store python file' repo alias name in main azure-pipeline yaml
- task: PythonScript@0
inputs:
scriptSource: 'filePath'
scriptPath: '$(System.DefaultWorkingDirectory)/python2'
3.Go to current repo and pipeline, add pr trigger and use the template created above:
pr:
branches:
include:
- main # modify as needed
paths:
include:
- README.md # modify as needed
variables:
acceptanceTestsRepoName: 'template' #the repo alias for 'store python file, you could change to whatever you want'
resources:
repositories:
- repository: template #the same with the above
name: {project name}/store python file #the real name of the repo
type: git
ref: main # modify as needed
stages:
- stage: A
displayName: AA
jobs:
- job: AAA
displayName: AAAA
pool:
vmImage: 'ubuntu-latest'
steps:
- template: 'template1@${{variables.acceptanceTestsRepoName}}'
Then after it was triggered and run, you are supposed to get things like this:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.