Skip to content

Commit 2c5e720

Browse files
authored
ci: add semgrep check (#477)
1 parent fbeff04 commit 2c5e720

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

.teamcity/builds/Build.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class Build(
3838
if (forPullRequests) dependentBuildType(PRCheck("${name}-pr-check", "pr check"))
3939

4040
parallel {
41+
dependentBuildType(SemgrepCheck("${name}-semgrep-check", "semgrep check"))
42+
4143
JavaPlatform.entries.forEach { java ->
4244
val packaging =
4345
Maven(

.teamcity/builds/Common.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ val MAVEN_DEFAULT_ARGS = buildString {
3333
}
3434
const val DEFAULT_BRANCH = "main"
3535

36+
const val FULL_GITHUB_REPOSITORY = "$GITHUB_OWNER/$GITHUB_REPOSITORY"
37+
const val GITHUB_URL = "https://github.com/$FULL_GITHUB_REPOSITORY"
38+
39+
const val SEMGREP_DOCKER_IMAGE = "semgrep/semgrep:1.146.0"
40+
3641
val DEFAULT_JAVA_VERSION = JavaVersion.V_11
3742
const val DEFAULT_CONFLUENT_PLATFORM_VERSION = "7.2.9"
3843

.teamcity/builds/Maven.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package builds
33
import jetbrains.buildServer.configs.kotlin.BuildType
44
import jetbrains.buildServer.configs.kotlin.toId
55

6-
class Maven(
6+
open class Maven(
77
id: String,
88
name: String,
99
goals: String,

.teamcity/builds/SemgrepCheck.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package builds
2+
3+
import jetbrains.buildServer.configs.kotlin.buildSteps.ScriptBuildStep
4+
5+
class SemgrepCheck(
6+
id: String,
7+
name: String
8+
): Maven(
9+
id,
10+
name,
11+
"dependency:tree",
12+
JavaVersion.V_17,
13+
Neo4jVersion.V_NONE,
14+
"-DoutputFile=maven_dep_tree.txt"
15+
) {
16+
17+
init {
18+
19+
params.password("env.SEMGREP_APP_TOKEN", "%semgrep-app-token%")
20+
params.text("env.SEMGREP_REPO_NAME", FULL_GITHUB_REPOSITORY)
21+
params.text("env.SEMGREP_REPO_URL", GITHUB_URL)
22+
params.text("env.SEMGREP_BRANCH", "%teamcity.build.branch%")
23+
params.text("env.SEMGREP_JOB_URL", "%env.BUILD_URL%")
24+
params.text("env.SEMGREP_COMMIT", "%env.BUILD_VCS_NUMBER%")
25+
26+
steps.step(ScriptBuildStep {
27+
scriptContent="semgrep ci --no-git-ignore"
28+
dockerImagePlatform = ScriptBuildStep.ImagePlatform.Linux
29+
dockerImage = SEMGREP_DOCKER_IMAGE
30+
dockerRunParameters =
31+
"--volume /var/run/docker.sock:/var/run/docker.sock --volume %teamcity.build.checkoutDir%/signingkeysandbox:/root/.gnupg"
32+
})
33+
}
34+
35+
}

.teamcity/settings.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ project {
1414
params {
1515
password("github-commit-status-token", "%github-token%")
1616
password("github-pull-request-token", "%github-token%")
17+
password("semgrep-app-token", "%semgrep-token%")
1718
}
1819

1920
vcsRoot(Neo4jKafkaConnectorVcs)

0 commit comments

Comments
 (0)