Template for a good new topic, formatted with Markdown :
Github for SCM (This is a Monorepo)
CircleCI
CircleCI orb scan command sonarcloud/scan
Languags are Typescript, terraform
Sonarcloud scan fails to find the configuration keys or file, with the below error
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.organization
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Exited with code exit status 2
Our configuration is as below, in sonar-project.properties
which is located in a monorepo sub-project under path ./packages/ui-project-1
Steps to reproduce
** This is reproducable when a build is executed.
Unsure of any workarounds, we have tried numerous configuration changes for CircleCI and sonarcloud.
We have the project imported in SC and set as a Monorepo, also the root Monorepo is imported into SC.
Colin
(Colin)
March 1, 2022, 10:17am
2
Hey there.
What does your .circleci/config.yml
file look like? Are you initiating the scan from the directory which contains your sonar-project.properties file (which contains both sonar.organization
and sonar.projectKey
)?
Hi Colin
Here is the circleCI config for the sub-project within the monorepo (located under packages/ui-switch-experimental), as far as I can tell we are initiating the scan from the directory that includes the project properties file see the working_directory: ~/project/packages/ui-switch-experimental
config
version: 2.1
prod-filters: &prod-filters
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
dev-branch-filters: &dev-branch-filters
branches:
only: /^((?!main).*)/
uat-filters: &uat-filters
branches:
only: main
orbs:
sonarcloud: sonarsource/sonarcloud@1.0.1
circleci-cli: circleci/circleci-cli@0.1.9
aws-ecr: circleci/aws-ecr@6.15.3
aws-ecs: circleci/aws-ecs@2.0.0
aws-s3: circleci/aws-s3@1.0.11
####################
# #
# JOBS #
# #
####################
jobs:
ui-switch-experimental-build:
working_directory: ~/project/packages/ui-switch-experimental
executor: node
parameters:
env:
type: string
default: uat
steps:
- common-load-project
- run:
name: Build
command: yarn build:<< parameters.env >>
- common-save-project
ui-experimental-sonarcloud:
executor: node
# working_directory: ~/project/packages/ui-experimental
steps:
- checkout
- sonarcloud/scan
ui-switch-experimental-dev-build:
working_directory: ~/project/packages/ui-switch-experimental
executor: node
parameters:
env:
type: string
default: uat
steps:
- common-load-project
- run:
name: Build
command: yarn build:<< parameters.env >>
ui-switch-experimental-test:
working_directory: ~/project/packages/ui-switch-experimental
executor: node
parallelism: 4
parameters:
env:
type: string
default: uat
steps:
- common-load-project
- run:
name: Run Linting
command: yarn lint
- run:
name: Run unit tests with coverage
command: yarn && yarn test:circleci
ui-switch-experimental-deploy:
working_directory: ~/project/packages/ui-switch-experimental
docker:
- image: circleci/python:2.7
parameters:
bucket-name:
type: string
steps:
- common-load-project
- common-check-dir-exists:
dir: ./build
- aws-s3/copy: # copy manifest and files that aren't hashed
from: ./build
to: "s3://<< parameters.bucket-name >>/"
arguments: |
--include "*" \
--exclude "*.html" \
--exclude "static/*" \
--cache-control "max-age=60" \
--recursive
- aws-s3/copy: # copy static files with hashed filenames, and set cache control to 1 year
from: ./build/static/
to: "s3://<< parameters.bucket-name >>/static/"
arguments: |
--include "*" \
--cache-control "max-age=31536000" \
--recursive
- aws-s3/copy: # copy web app .html files
from: ./build
to: "s3://<< parameters.bucket-name >>/"
arguments: |
--exclude "*" \
--include "*.html" \
--content-type "text/html; charset=utf-8" \
--cache-control "max-age=60" \
--recursive
ui-switch-experimental-schema-build:
working_directory: ~/project/packages/schema
executor: node
steps:
- common-load-project
- run:
name: Compile GraphQL Schema
command: yarn compile:schema
- run:
name: Compile Types
command: yarn compile:types
- common-save-project
#########################
# #
# WORKFLOWS #
# #
#########################
workflows:
"UI Experimental [Test] (BRANCH)":
jobs:
- common-node-setup:
name: Setup ui-switch-experimental (BRANCH)
context: au-aws-uat
cache-key: yarn-packages-{{ checksum "./packages/ui-switch-experimental/yarn.lock" }}
filters:
<<: *dev-branch-filters
- ui-switch-experimental-schema-build:
name: Build Schema (BRANCH)
context: au-aws-uat
requires:
- Setup ui-switch-experimental (BRANCH)
filters:
<<: *dev-branch-filters
- ui-switch-experimental-test:
name: Test ui-switch-experimental (BRANCH)
context: au-aws-uat
env: uat
requires:
- Build Schema (BRANCH)
filters:
<<: *dev-branch-filters
- ui-switch-experimental-dev-build:
name: Build ui-switch-experimental (BRANCH)
context: au-aws-uat
env: uat
requires:
- Build Schema (BRANCH)
filters:
<<: *dev-branch-filters
- ui-experimental-sonarcloud:
name: Run Sonarcloud analysis on ui-experimental (BRANCH)
filters:
<<: *dev-branch-filters
"UI Experimental [Test & Deploy] (UAT)":
jobs:
- common-node-setup:
name: Setup ui-switch-experimental (UAT)
context: au-aws-uat
cache-key: yarn-packages-{{ checksum "./packages/ui-switch-experimental/yarn.lock" }}
filters:
<<: *uat-filters
- ui-switch-experimental-schema-build:
name: Build Schema (UAT)
context: au-aws-uat
requires:
- Setup ui-switch-experimental (UAT)
filters:
<<: *uat-filters
- ui-switch-experimental-test:
name: Test ui-switch-experimental (UAT)
context: au-aws-uat
env: uat
requires:
- Build Schema (UAT)
filters:
<<: *uat-filters
- ui-switch-experimental-build:
name: Build ui-switch-experimental (UAT)
context: au-aws-uat
env: uat
requires:
- Build Schema (UAT)
filters:
<<: *uat-filters
- ui-switch-experimental-deploy:
name: Deploy ui-switch-experimental (UAT)
context: au-aws-uat
bucket-name: ovoenergyau-uat-switch-experimental-bucket
requires:
- Test ui-switch-experimental (UAT)
- Build ui-switch-experimental (UAT)
filters:
<<: *uat-filters
- ui-switch-experimental-deploy:
name: Deploy ui-switch-experimental (switch2) (UAT)
context: au-aws-uat
bucket-name: ovoenergyau-uat-switch-ui-bucket
requires:
- Test ui-switch-experimental (UAT)
- Build ui-switch-experimental (UAT)
filters:
<<: *uat-filters
"UI Experimental [Test & Deploy] (PROD)":
jobs:
- common-node-setup:
name: Setup ui-switch-experimental (PROD)
context: au-aws-prod
cache-key: yarn-packages-{{ checksum "./packages/ui-switch-experimental/yarn.lock" }}
filters:
<<: *prod-filters
- ui-switch-experimental-schema-build:
name: Build Schema (PROD)
context: au-aws-prod
requires:
- Setup ui-switch-experimental (PROD)
filters:
<<: *prod-filters
- ui-switch-experimental-build:
name: Build ui-switch-experimental (PROD)
context: au-aws-prod
env: prod
requires:
- Build Schema (PROD)
filters:
<<: *prod-filters
- ui-switch-experimental-test:
name: Test ui-switch-experimental (PROD)
context: au-aws-prod
env: prod
requires:
- Build Schema (PROD)
filters:
<<: *prod-filters
- hold:
name: Hold ui-switch-experimental Deploy (PROD)
type: approval
requires:
- Test ui-switch-experimental (PROD)
- Build ui-switch-experimental (PROD)
filters:
<<: *prod-filters
- ui-switch-experimental-deploy:
name: Deploy ui-switch-experimental (PROD)
context: au-aws-prod
bucket-name: ovoenergyau-prod-switch-experimental-bucket
requires:
- Hold ui-switch-experimental Deploy (PROD)
filters:
<<: *prod-filters
- hold:
name: Hold ui-switch-experimental (switch2) Deploy (PROD)
type: approval
requires:
- Hold ui-switch-experimental Deploy (PROD)
- Deploy ui-switch-experimental (PROD)
filters:
<<: *prod-filters
- ui-switch-experimental-deploy:
name: Deploy ui-switch-experimental (switch2) (PROD)
context: au-aws-uat
bucket-name: ovoenergyau-prod-switch-ui-bucket
requires:
- Hold ui-switch-experimental (switch2) Deploy (PROD)
filters:
<<: *uat-filters
Hello @howyagoin ,
I added a property project_root
property to the orb, this will allow you to set the sub-directory so that the scan only takes into account that sub-directory. You can see the changes here .
Can you try it out and let me know if that fixes your issue? You’ll have to use version 1.1.0 of the orb.
2 Likes
Hi there Tom - confirming that has worked perfectly! Thanks very much for your support and getting that fixed in the Orb. Have a great one
3 Likes
system
(system)
Closed
June 6, 2022, 12:13pm
12
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.