Skip to content

Commit 6b0ad14

Browse files
committed
chore: update config to read PR number
Signed-off-by: Arjun Rajappa <Arjun.Rajappa@ibm.com>
1 parent dfaef4b commit 6b0ad14

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.circleci/config.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,23 @@ commands:
136136
environment:
137137
SONAR_TOKEN: $SONAR_TOKEN
138138
command: |
139-
export SONAR_SCANNER_VERSION=7.2.0.5079
139+
#!/usr/bin/env bash
140+
141+
PR_NUMBER=$(echo ${CIRCLE_PULL_REQUEST} | sed 's/.*\///')
142+
SONAR_SCANNER_VERSION=${SONAR_SCANNER_VERSION}
140143
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
144+
SONAR_TOKEN=${SONAR_TOKEN}
141145
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
142146
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
143147
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
144148
export SONAR_SCANNER_OPTS="-server"
145-
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
149+
if [[ -n "${PR_NUMBER}" ]]; then
146150
sonar-scanner \
147151
-Dsonar.organization=instana \
148152
-Dsonar.projectKey=instana_ruby-sensor \
149153
-Dsonar.sources=. \
150154
-Dsonar.host.url="${SONARQUBE_URL}" \
151-
-Dsonar.pullrequest.key="${CIRCLE_PR_NUMBER}" \
155+
-Dsonar.pullrequest.key="${PR_NUMBER}" \
152156
-Dsonar.pullrequest.branch="${CIRCLE_BRANCH}"
153157
else
154158
sonar-scanner \

0 commit comments

Comments
 (0)