Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
mh | 24fbc1304d | 4 months ago |
mh | 714e113a0d | 5 months ago |
mh | 0baa759bcd | 5 months ago |
mh | 9fbfdb27de | 5 months ago |
mh | e00ad516b0 | 5 months ago |
mh | 488634e59a | 5 months ago |
mh | 79a7128fbd | 5 months ago |
mh | 1923685565 | 5 months ago |
mh | 4fbf06d6e7 | 5 months ago |
mh | 554a4d498c | 5 months ago |
mh | fd9ea41c4b | 5 months ago |
mh | 704aeaa91a | 5 months ago |
mh | 92875c14ab | 5 months ago |
mh | 61528d0031 | 5 months ago |
mh | d03ce5630b | 5 months ago |
mh | a866084bea | 5 months ago |
mh | aeddb9f3e2 | 5 months ago |
mh | 0151ed7213 | 5 months ago |
mh | a3cb58be42 | 5 months ago |
mh | db487d8174 | 5 months ago |
mh | 675fb8278d | 5 months ago |
mh | 24ed37f4b7 | 5 months ago |
Mohammadhosain | fb87b1161f | 5 months ago |
7 changed files with 156 additions and 1 deletions
@ -0,0 +1,84 @@ |
|||
pipeline { |
|||
agent any |
|||
|
|||
environment { |
|||
GITEA_CREDS = 'testtest' |
|||
GITEA_REPO_OWNER = 'mh' |
|||
GITEA_REPO_NAME = 'TEst' |
|||
GITEA_SERVER = 'http://194.5.205.38:3000' |
|||
GITEA_TOKEN = '090ac0a087634a808792833fa23368d100ec03d9' |
|||
MAIN_BRANCH = 'master' |
|||
} |
|||
|
|||
stages { |
|||
stage('Clone the repo') { |
|||
steps { |
|||
echo "Clone the repo" |
|||
sh "rm -fr jenkins-test3" |
|||
git branch: "${env.MAIN_BRANCH}", credentialsId: "${env.GITEA_CREDS}", url: "${env.GITEA_SERVER}/${env.GITEA_REPO_OWNER}/${env.GITEA_REPO_NAME}.git" |
|||
} |
|||
} |
|||
stage('Code Analysis') { |
|||
parallel { |
|||
stage('CppCheck') { |
|||
steps { |
|||
sleep 3 |
|||
sh 'cppcheck_configs/cpp_check_scripts.sh' |
|||
} |
|||
} |
|||
stage('Clang Tidy') { |
|||
steps { |
|||
sh 'clang_configs/clang_tidy_script.sh' |
|||
} |
|||
} |
|||
|
|||
stage('Clang Format') { |
|||
steps { |
|||
sh 'clang_configs/clang_format_script.sh' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
stage('Deploy') { |
|||
steps { |
|||
sleep 10 |
|||
echo "Deploy" |
|||
} |
|||
} |
|||
stage('Cleaning') { |
|||
steps { |
|||
sh "rm -fr ${env.GITEA_REPO_NAME}" |
|||
} |
|||
} |
|||
} |
|||
|
|||
post { |
|||
always { |
|||
script { |
|||
def status = currentBuild.result == 'SUCCESS' ? 'success' : 'failure' |
|||
def state = status == 'success' ? 'success' : 'failure' |
|||
def description = "Jenkins build ${status}" |
|||
def commitSha = env.GIT_COMMIT |
|||
|
|||
def apiUrl = "${env.GITEA_SERVER}/api/v1/repos/${env.GITEA_REPO_OWNER}/${env.GITEA_REPO_NAME}/statuses/${commitSha}" |
|||
|
|||
httpRequest( |
|||
url: apiUrl, |
|||
httpMode: 'POST', |
|||
customHeaders: [ |
|||
[name: 'Content-Type', value: 'application/json'], |
|||
[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"] |
|||
], |
|||
requestBody: """ |
|||
{ |
|||
"state": "${state}", |
|||
"target_url": "${env.BUILD_URL}", |
|||
"description": "${description}", |
|||
"context": "continuous-integration/jenkins" |
|||
} |
|||
""" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
#!/bin/bash |
|||
|
|||
# Find all C++ files in the project directory and its subdirectories |
|||
files=$(find . -name "*.cpp") |
|||
|
|||
# Iterate over each file |
|||
for file in $files; do |
|||
clang-format "$file" > format_errors.txt 2>&1 |
|||
|
|||
# Compare the original file with the formatted version |
|||
if ! cmp -s "$file" format_errors.txt; then |
|||
echo "Formatting failed for file: $file. Reasons:" |
|||
cat format_errors.txt |
|||
exit 1 |
|||
fi |
|||
done |
|||
|
|||
echo "Formatting successful for all files." |
@ -0,0 +1,18 @@ |
|||
#!/bin/bash |
|||
|
|||
# Find all C++ files in the project directory and its subdirectories |
|||
files=$(find . -name "*.cpp") |
|||
|
|||
for file in $files; do |
|||
echo "Running clang-tidy for file: $file" |
|||
clangTidyOutput=$(clang-tidy "$file" -- -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -DMY_DEFINES ...) |
|||
echo "$clangTidyOutput" |
|||
|
|||
# Check if clang-tidy found any warnings |
|||
if [[ $clangTidyOutput == *"warning:"* ]]; then |
|||
echo "clang-tidy found warnings in file: $file" |
|||
echo "$clangTidyOutput" |
|||
exit 1 |
|||
fi |
|||
done |
|||
echo "clang-tidy done successful for all files." |
@ -0,0 +1,25 @@ |
|||
#!/bin/bash |
|||
|
|||
# Find all C++ files in the project directory and its subdirectories |
|||
files=$(find . -name "*.cpp") |
|||
|
|||
# Iterate over each file |
|||
for file in $files; do |
|||
# Run cppcheck for the current file and capture its output in XML format |
|||
cppcheck --enable=all --suppress=missingIncludeSystem --xml --language=c++ -i cppcheck.xml --enable=all --inconclusive --debug --template=gcc "$file" 2>> cppcheck-result.xml |
|||
|
|||
# Read the cppcheck result XML file for the current file |
|||
cppcheckOutput=$(cat cppcheck-result.xml) |
|||
|
|||
# Check if cppcheck found any errors for the current file |
|||
if grep -q '<error ' cppcheck-result.xml; then |
|||
# Print cppcheck output for debugging |
|||
echo "cppcheck found errors in file: $file" |
|||
echo "$cppcheckOutput" |
|||
|
|||
# Exit with non-zero status to indicate failure |
|||
exit 1 |
|||
fi |
|||
done |
|||
|
|||
echo "cppcheck successful. No errors found." |
@ -1 +1 @@ |
|||
Hello World! |
|||
Hello World!@!!!aabfvv!!44 |
@ -0,0 +1,9 @@ |
|||
#include <stdio.h> |
|||
|
|||
int main() { |
|||
int a = 5; |
|||
int b = 10; |
|||
int sum = a + b; |
|||
printf("Sum: %d\n", sum); |
|||
return 0; |
|||
} |
@ -1 +1,2 @@ |
|||
adfdfasd |
|||
## PLEASE STAY2 |
Loading…
Reference in new issue