Compare commits
20
Commits
9f83d24389
...
pullone
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d315dfff9 | ||
|
|
8ab4197aab | ||
|
|
f7036c59b8 | ||
|
|
8bf5a6ff54 | ||
|
|
4fb07a618d | ||
|
|
294cebf0f7 | ||
|
|
d5dff17d10 | ||
|
|
f19564431b | ||
|
|
339028b826 | ||
|
|
f8c1ba3763 | ||
|
|
ef047dec21 | ||
|
|
3734ceee33 | ||
|
|
4cb1102b56 | ||
|
|
0fb7051c93 | ||
|
|
e9edfcd11a | ||
|
|
e7dbe62d2a | ||
|
|
d072b7c55f | ||
|
|
1ab855a5db | ||
|
|
d31f8b1250 | ||
|
|
ef4d6ae81b |
+71
-19
@@ -2,10 +2,17 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
COVERITY_URL = 'http://coverity.etechtips.com'
|
COVERITY_URL = 'https://coverity.etechtips.com'
|
||||||
COVERITY_STREAM = 'agone-full'
|
COVERITY_STREAM = 'agone-full'
|
||||||
|
COVERITY_PR_STREAM = 'agone-pr'
|
||||||
// Add Coverity binaries to PATH if not globally set on the Jenkins agent
|
// Add Coverity binaries to PATH if not globally set on the Jenkins agent
|
||||||
PATH = "/opt/coverity/analysis/bin:${env.PATH}"
|
PATH = "/opt/coverity/analysis/bin:${env.PATH}"
|
||||||
|
|
||||||
|
// Full-build baseline artifact
|
||||||
|
COVERITY_BASELINE_ARCHIVE = 'agone-full-cov-int.tar.gz'
|
||||||
|
|
||||||
|
//For a Multibranch Pipeline
|
||||||
|
AGONE_FULL_JOB = 'agone/main'
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
@@ -25,14 +32,18 @@ COVERITY_URL = 'http://coverity.etechtips.com'
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "Starting agone-full build..."
|
echo "Starting agone-full build..."
|
||||||
|
echo "The current branch is: ${env.BRANCH_NAME}"
|
||||||
|
|
||||||
// 1. Clean previous Coverity intermediate directory
|
// 1. Clean previous Coverity intermediate directory
|
||||||
sh 'rm -rf cov-int'
|
sh 'rm -rf cov-int'
|
||||||
|
|
||||||
|
// Clean Bazel outputs
|
||||||
|
sh 'bazel clean'
|
||||||
|
|
||||||
// 2. Run full Bazel build wrapped in cov-build
|
// 2. Run full Bazel build wrapped in cov-build
|
||||||
// --spawn_strategy=standalone ensures Coverity intercepts compiler processes
|
// --spawn_strategy=standalone ensures Coverity intercepts compiler processes
|
||||||
sh '''
|
sh '''
|
||||||
cov-build --dir cov-int \
|
cov-build --dir cov-int --bazel \
|
||||||
bazel build --spawn_strategy=standalone //:run
|
bazel build --spawn_strategy=standalone //:run
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -45,14 +56,29 @@ bazel build --spawn_strategy=standalone //:run
|
|||||||
passwordVariable: 'COV_PASSWORD',
|
passwordVariable: 'COV_PASSWORD',
|
||||||
usernameVariable: 'COV_USER'
|
usernameVariable: 'COV_USER'
|
||||||
)]) {
|
)]) {
|
||||||
sh """
|
sh '''
|
||||||
cov-commit-defects --dir cov-int \
|
cov-commit-defects --dir cov-int \
|
||||||
--url ${COVERITY_URL} \
|
--url "${COVERITY_URL}" \
|
||||||
--stream ${COVERITY_STREAM} \
|
--stream "${COVERITY_STREAM}" \
|
||||||
--user ${COV_USER} \
|
--user "${COV_USER}" \
|
||||||
--password ${COV_PASSWORD}
|
--password "${COV_PASSWORD}"
|
||||||
"""
|
'''
|
||||||
}
|
}
|
||||||
|
// 5. Package the completed full-build intermediate directory
|
||||||
|
sh '''
|
||||||
|
rm -f "${COVERITY_BASELINE_ARCHIVE}"
|
||||||
|
tar -czf "${COVERITY_BASELINE_ARCHIVE}" cov-int
|
||||||
|
test -s "${COVERITY_BASELINE_ARCHIVE}"
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
// 6. Store Baseline as a jenkins artifact
|
||||||
|
archiveArtifacts (
|
||||||
|
artifacts: "${COVERITY_BASELINE_ARCHIVE}",
|
||||||
|
fingerprint: true,
|
||||||
|
onlyIfSuccessful: true
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,14 +96,24 @@ bazel build --spawn_strategy=standalone //:run
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "Starting agone-pr build..."
|
echo "Starting agone-pr build..."
|
||||||
|
echo "The current branch is: ${env.BRANCH_NAME}"
|
||||||
|
|
||||||
// 1. Determine target branch and fetch changes
|
// 1. Determine target branch and fetch changes
|
||||||
def targetBranch = env.CHANGE_TARGET ?: 'main'
|
def targetBranch = env.CHANGE_TARGET ?: 'main'
|
||||||
sh "git fetch origin ${targetBranch}"
|
|
||||||
|
|
||||||
// 2. Identify changed files relative to the target branch
|
sh """
|
||||||
|
git fetch origin \
|
||||||
|
+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}
|
||||||
|
"""
|
||||||
|
def mergeBase = sh(
|
||||||
|
script: "git merge-base HEAD origin/${targetBranch}",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
echo "Merge base: ${mergeBase}"
|
||||||
|
|
||||||
def changedFiles = sh(
|
def changedFiles = sh(
|
||||||
script: "git diff --name-only origin/${targetBranch}...HEAD",
|
script: "git diff --name-only ${mergeBase} HEAD",
|
||||||
returnStdout: true
|
returnStdout: true
|
||||||
).trim()
|
).trim()
|
||||||
|
|
||||||
@@ -104,22 +140,38 @@ bazel build --spawn_strategy=standalone //:run
|
|||||||
|
|
||||||
echo "Affected Bazel targets:\n${affectedTargets}"
|
echo "Affected Bazel targets:\n${affectedTargets}"
|
||||||
|
|
||||||
// 4. Clean PR-specific Coverity directory
|
copyArtifacts (
|
||||||
sh 'rm -rf cov-int-pr'
|
projectName: "${AGONE_FULL_JOB}",
|
||||||
|
selector: last_successful(),
|
||||||
|
filter: "${COVERITY_BASELINE_ARCHIVE}",
|
||||||
|
fingerprintArtifacts: true
|
||||||
|
)
|
||||||
|
|
||||||
|
// 4a. recover nightly pr
|
||||||
|
sh '''
|
||||||
|
rm -rf cov-int-pr baseline-cov-int
|
||||||
|
mkdir baseline-cov-int
|
||||||
|
tar -xzf "${COVERITY_BASELINE_ARCHIVE}" \
|
||||||
|
-C baseline-cov-int
|
||||||
|
test -d baseline-cov-int/cov-int
|
||||||
|
|
||||||
|
mv baseline-cov-int/cov-int cov-int-pr
|
||||||
|
rmdir baseline-cov-int
|
||||||
|
'''
|
||||||
|
|
||||||
// 5. Build only the affected targets wrapped in cov-build
|
// 5. Build only the affected targets wrapped in cov-build
|
||||||
sh """
|
sh """
|
||||||
cov-build --dir cov-int-pr \
|
cov-build --dir cov-int-pr --bazel \
|
||||||
bazel build --spawn_strategy=standalone ${affectedTargets.replaceAll('\n', ' ')}
|
bazel build --spawn_strategy=standalone ${affectedTargets.replaceAll('\n', ' ')}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
// 6. Run fast desktop analysis on only changed files
|
// 6. Run fast desktop analysis on only changed files
|
||||||
sh """
|
sh '''
|
||||||
cov-run-desktop --dir cov-int-pr \
|
cov-run-desktop --dir cov-int-pr \
|
||||||
--target-url ${COVERITY_URL} \
|
--target-url "${COVERITY_URL}" \
|
||||||
--stream ${COVERITY_STREAM} \
|
--stream "${COVERITY_PR_STREAM}" \
|
||||||
${changedFiles.replaceAll('\n', ' ')}
|
${changedFiles.replaceAll('\n', ' ')}
|
||||||
"""
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user