在使用 qodana 进行代码扫描时,如果项目依赖于私有 maven 仓库,则需要将访问仓库的用户名和密码传递给 qodana。一种常见的方法是使用 args 参数,将环境变量传递给 qodana 扫描。然而,如果配置不正确,可能会导致构建失败,并出现类似 "the following gradle properties are missing" 的错误。
问题的根源在于 args 参数中,环境变量的传递方式。正确的配置方式是使用逗号 , 分隔 -e 和环境变量名。
以下是错误的配置示例:
- name: 'Qodana Scan' uses: JetBrains/<a class="__cf_email__" data-cfemail="7a0b151e1b141b571b190e1315143a0c484a484854485449" href="/cdn-cgi/l/email-protection">[email protected]</a> with: args: -e ORG_GRADLE_PROJECT_onstructiveUsername=${{ secrets.M2_USER }},-e ORG_GRADLE_PROJECT_onstructivePassword=${{ secrets.M2_PWD }}
正确的配置示例:
- name: 'Qodana Scan' uses: JetBrains/<a class="__cf_email__" data-cfemail="6918060d08070845080a1d000607291f5b595b5b475b475a" href="/cdn-cgi/l/email-protection">[email protected]</a> with: args: -e,ORG_GRADLE_PROJECT_onstructiveUsername=${{ secrets.M2_USER }},-e,ORG_GRADLE_PROJECT_onstructivePassword=${{ secrets.M2_PWD }}
关键的区别在于,-e 和环境变量名之间使用了逗号 , 进行分隔。
以下是一个完整的 GitHub Actions YAML 配置文件示例,展示了如何正确地将环境变量传递给 Qodana 扫描:
name: Qodana on: workflow_dispatch: pull_request: push: branches: - '[0-9]+.[0-9]+.x' jobs: qodana: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: 'Qodana Scan' uses: JetBrains/<a class="__cf_email__" data-cfemail="75041a11141b14581416011c1a1b3503474547475b475b46" href="/cdn-cgi/l/email-protection">[email protected]</a> with: args: -e,ORG_GRADLE_PROJECT_onstructiveUsername=${{ secrets.M2_USER }},-e,ORG_GRADLE_PROJECT_onstructivePassword=${{ secrets.M2_PWD }}
正确地将环境变量传递给 Qodana 扫描是确保代码质量检查顺利进行的关键。通过使用逗号 , 分隔 -e 和环境变量名,可以避免因凭据缺失导致的构建失败。希望本文能够帮助您在使用 GitHub Actions 运行 Qodana 时,成功传递环境变量,并获得准确的代码质量分析结果。
以上就是GitHub Actions 中使用 Qodana 传递环境变量的正确方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号