Created
October 14, 2019 06:21
-
-
Save alfredfrancis/bece4924dcc87bb622cd074a010e6c85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: python:3.7.4 | |
pipelines: | |
default: | |
- step: | |
script: | |
- pip install -r requirements.txt | |
- python -m unittest discover tests/ | |
- step: | |
caches: | |
- sonar | |
script: | |
- apt-get update; apt-get install -y jq unzip | |
- export BITBUCKET_ACCESS_TOKEN=$(curl -s -X POST -u "$OAUTH_CLIENT_KEY:$OAUTH_CLIENT_SECRET" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials | jq ".access_token") | |
- export BITBUCKET_PULL_REQUEST_ID=$(curl -s -XGET "https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/pullrequests?pagelen=5&state=OPEN&access_token=$BITBUCKET_ACCESS_TOKEN" | jq ".values[] | select(.source.branch.name==\"$BITBUCKET_BRANCH\") | .id") | |
- curl --insecure -OL https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip | |
- unzip sonar-scanner-cli-3.2.0.1227-linux.zip | |
- export SONAR_SCANNER_OPTS="-Xmx1024m" | |
- if [ -n $BITBUCKET_PULL_REQUEST_ID ]; then ./sonar-scanner-3.2.0.1227-linux/bin/sonar-scanner -Dproject.settings=sonar-project.properties -Dsonar.analysis.mode=issues -Dsonar.bitbucket.repoSlug=$BITBUCKET_REPO_SLUG -Dsonar.bitbucket.accountName=$BITBUCKET_REPO_OWNER -Dsonar.bitbucket.branchName=$BITBUCKET_BRANCH -Dsonar.bitbucket.oauthClientKey=$OAUTH_CLIENT_KEY -Dsonar.bitbucket.oauthClientSecret=$OAUTH_CLIENT_SECRET -Dsonar.login=$SONAR_LOGIN -Dsonar.bitbucket.pullRequestId=$BITBUCKET_PULL_REQUEST_ID; fi | |
definitions: | |
caches: | |
sonar: /root/.sonar/cache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment