我想将 git diff shell 脚本的输出检索到变量中,然后在其上运行用户定义的函数。我如何声明我想要编写的这些函数以及如何使用它们?
pipeline{
agent any
parameters {
string(name: 'branchA', defaultValue: 'master', description: 'Comapare which branch?')
string(name: 'branchB', defaultValue: 'dev', description: 'Compare with which branch?')
}
stages {
stage('Build') {
steps{
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanBeforeCheckout']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'gitCreds', url: "https://github.com/DialgicMew/example.git"]]])
sh "git diff --name-only remotes/origin/${params.branchA} remotes/origin/${params.branchB}"
}
stage('Functions on the result') {
steps{
echo "Functions to be used here"
}
}
}
}
```
Run Code Online (Sandbox Code Playgroud)