Skip to content

Commit

Permalink
SONARGRADL-125 Add mend task (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
irina-batinic-sonarsource authored Jul 6, 2023
1 parent 387a90c commit c109938
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ container_definition_17: &CONTAINER_DEFINITION_17
region: eu-central-1
namespace: default

setup_gradle_cache_template: &SETUP_GRADLE_CACHE
gradle_cache:
folder: .gradle/caches
create_gradle_directory_script:
- mkdir -p "${CIRRUS_WORKING_DIR}/.gradle"

only_sonarsource_qa: &ONLY_SONARSOURCE_QA
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "dogfood-on-.*")

Expand Down Expand Up @@ -88,6 +94,33 @@ build_task:
path: "**/test-results/**/*.xml"
format: junit

mend_scan_task:
<<: *SETUP_GRADLE_CACHE
depends_on:
- build
# run only on master and long-living branches
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "mend-.*")
eks_container:
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j18-latest
region: eu-central-1
cluster_name: ${CIRRUS_CLUSTER_NAME}
namespace: default
cpu: 4
memory: 2G
env:
WS_APIKEY: VAULT[development/kv/data/mend data.apikey]
maven_cache:
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
mend_script:
- source cirrus-env QA
- ./gradlew clean build -x test
- source ./export_ws_variables.sh
- source ws_scan.sh
allow_failures: "true"
always:
ws_scan_artifacts:
path: "whitesource/**/*"

gradle_qa_java11_task:
depends_on:
- build
Expand Down
23 changes: 23 additions & 0 deletions export_ws_variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /usr/bin/env bash

set -euox pipefail

get_project_version() {
local version_property
version_property=$(./gradlew properties | grep --extended-regexp "^version: (.*)")
if [[ -z "${version_property}" ]]; then
echo "Could not find property version in project" >&2
exit 2
fi
local version
version=$(echo "${version_property}" | tr --delete "[:space:]" | cut --delimiter=":" --fields=2)
version="${version/-SNAPSHOT/}"
# Because the ws scan script expects a semver-like version (aa.bb.cc.XX), we append the build number to the project version.
if [[ "${version}" =~ ^[0-9]+\.[0-9]+$ ]]; then
version="${version}.0"
fi
version="${version}.${BUILD_NUMBER:-0}"
echo "${version}"
}

export PROJECT_VERSION="$(get_project_version)"
14 changes: 14 additions & 0 deletions wss-unified-agent.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
excludes=**/integrationTests/** **/*javadoc.jar
fileSystemScan=False
resolveAllDependencies=False

gradle.aggregateModules=True
gradle.preferredEnvironment=wrapper
gradle.resolveDependencies=True
gradle.excludeModules=integrationTests

wss.url=https://saas-eu.whitesourcesoftware.com/agent

forceUpdate=true
checkPolicies=true
forceUpdate.failBuildOnPolicyViolation=true

0 comments on commit c109938

Please sign in to comment.