admin管理员组文章数量:1122846
I have azure pipeline created from yml file code-analysis-pipeline.yml in repository which is on the same level as gradle.properties. On gradle.properties there is a variable VERSION_CODE and on code-anlysis-pipeline.yml, I need to access the VERSION_CODE variable. Is there anyway to access this variable from the yml file?
- task: PowerShell@2
displayName: Run gradle sonar
inputs:
targetType: 'inline'
pwsh: true
workingDirectory: ${{ parameters.workingDirectory }}
script: |
$GRADLE_COMMAND = "./gradlew sonar"
$GRADLE_COMMAND += " ""-Dsonar.projectVersion=$(VERSION_CODE_FROM_GRADLE_PROPERTIES)"""
I have azure pipeline created from yml file code-analysis-pipeline.yml in repository which is on the same level as gradle.properties. On gradle.properties there is a variable VERSION_CODE and on code-anlysis-pipeline.yml, I need to access the VERSION_CODE variable. Is there anyway to access this variable from the yml file?
- task: PowerShell@2
displayName: Run gradle sonar
inputs:
targetType: 'inline'
pwsh: true
workingDirectory: ${{ parameters.workingDirectory }}
script: |
$GRADLE_COMMAND = "./gradlew sonar"
$GRADLE_COMMAND += " ""-Dsonar.projectVersion=$(VERSION_CODE_FROM_GRADLE_PROPERTIES)"""
Share
Improve this question
asked yesterday
Kevin LeeKevin Lee
3554 silver badges11 bronze badges
1 Answer
Reset to default 0you are using an powershell task, might just read the file and then filter the line by key name?
- task: PowerShell@2
displayName: Run gradle sonar
inputs:
targetType: 'inline'
pwsh: true
workingDirectory: ${{ parameters.workingDirectory }}
script: |
$searchText = "VERSION_CODE"
$filteredLine = Get-Content -Path 'gradle.properties' | Select-String -Pattern $searchText
if ($filteredLine) {
$splitLine = $filteredLine -split '='
$version = $splitLine[1].Trim()
$version
}
$GRADLE_COMMAND = "./gradlew sonar"
$GRADLE_COMMAND += " ""-Dsonar.projectVersion=$(version)"""
本文标签: androidGetting variable from gradleproperties to Azure DevOps pipeline ymlStack Overflow
版权声明:本文标题:android - Getting variable from gradle.properties to Azure DevOps pipeline yml - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283415a1926961.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论