-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
- Loading branch information
1 parent
d47725d
commit bce0434
Showing
5 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
job("Gradle_Check_backup") { | ||
description("Test") | ||
keepDependencies(false) | ||
parameters { | ||
stringParam("sha1", "main", "") | ||
} | ||
scm { | ||
git { | ||
remote { | ||
name("origin") | ||
github("opensearch-project/OpenSearch", "https") | ||
} | ||
branch("\${sha1}") | ||
} | ||
} | ||
disabled(true) | ||
triggers { | ||
githubPullRequest { | ||
cron("H/2 * * * *") | ||
permitAll(false) | ||
triggerPhrase(".*start\\W+gradle\\W+check.*") | ||
} | ||
} | ||
concurrentBuild(true) | ||
steps { | ||
shell("""#!/bin/bash | ||
bash opensearch-infra/jenkins/jobs/OpenSearch_CI/PR_Checks/Gradle_Check/gradle-check-assemble.sh""") | ||
} | ||
publishers { | ||
archiveArtifacts { | ||
pattern("gradle_check_\${BUILD_NUMBER}*") | ||
allowEmpty(false) | ||
onlyIfSuccessful(false) | ||
fingerprint(false) | ||
defaultExcludes(true) | ||
} | ||
} | ||
wrappers { | ||
preBuildCleanup { | ||
deleteDirectories(false) | ||
cleanupParameter() | ||
} | ||
timeout { | ||
absolute(120) | ||
} | ||
timestamps() | ||
} | ||
configure { | ||
it / 'properties' / 'jenkins.model.BuildDiscarderProperty' { | ||
strategy { | ||
'daysToKeep'('-1') | ||
'numToKeep'('150') | ||
'artifactDaysToKeep'('-1') | ||
'artifactNumToKeep'('-1') | ||
} | ||
} | ||
it / 'properties' / 'com.coravy.hudson.plugins.github.GithubProjectProperty' { | ||
'projectUrl'('https://github.com/opensearch-project/OpenSearch/') | ||
displayName() | ||
} | ||
it / 'properties' / 'com.sonyericsson.rebuild.RebuildSettings' { | ||
'autoRebuild'('false') | ||
'rebuildDisabled'('false') | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
IFS=`echo -ne "\n\b"` | ||
|
||
docker ps | ||
docker stop `docker ps -qa` > /dev/null 2>&1 | ||
|
||
cd search | ||
|
||
echo "./gradlew check --no-daemon --no-scan" | ||
./gradlew check --no-daemon --no-scan | ||
GRADLE_CHECK_STATUS=$? | ||
|
||
|
||
# Archive reports | ||
cd ../ | ||
REPORTS_DIR=`find ./search -name reports` | ||
zip -9 -q -r gradle_check_${BUILD_NUMBER}_reports.zip ${REPORTS_DIR} | ||
ls | grep "gradle_check_${BUILD_NUMBER}" | ||
|
||
if [ "$GRADLE_CHECK_STATUS" != 0 ] | ||
then | ||
echo Gradle Check Failed! | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pipeline { | ||
agent any | ||
|
||
stages { | ||
stage('gradle-check') { | ||
steps { | ||
sh('./search/jenkins/gradle-check-assemble.sh') | ||
} | ||
|
||
} | ||
} | ||
|
||
post { | ||
success { | ||
sh('./search/jenkins/post-build-task1.sh') | ||
} | ||
failure { | ||
sh('./search/jenkins/post-build-task2.sh') | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
JOB_NAME_TEMP=`basename "$JOB_NAME"` | ||
LOG_NAME="gradle_check_${BUILD_NUMBER}.log" | ||
|
||
sed -i -n -e "/\[$JOB_NAME_TEMP\]/,/ConsoleLogToWorkspace/p" $LOG_NAME | ||
sed -i '/ConsoleLogToWorkspace/d' $LOG_NAME | ||
sed -i 's/jenkins/CITOOL/g' $LOG_NAME | ||
sed -i 's/Jenkins/CITOOL/g' $LOG_NAME | ||
sed -i 's/workspace/workflow/g' $LOG_NAME | ||
sed -i 's/Workspace/workflow/g' $LOG_NAME |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
OLDIFS=$IFS | ||
ISSUE_TITLE="Jenkins Randomized Gradle Check Failed on ${sha1}" | ||
|
||
############################################### | ||
|
||
function create_issue() { | ||
|
||
echo create new issue | ||
|
||
curl -X "POST" "https://api.github.com/repos/opensearch-project/OpenSearch/issues?state=all" \ | ||
-H "Cookie: logged_in=no" \ | ||
-H "Authorization: token $GITHUB_PASSWORD_CREDENTIAL" \ | ||
-H "Content-Type: text/x-markdown; charset=utf-8" \ | ||
-d $'{ | ||
"title": "'$ISSUE_TITLE'", | ||
"body": "@opensearch-project/opensearch-core team, please take a look at Build '${BUILD_NUMBER}' in gradle_check log for more information.", | ||
"labels": [ | ||
"cicd", | ||
"bug" | ||
] | ||
}' > create_issue_output.json | ||
|
||
} | ||
|
||
############################################### | ||
|
||
echo $sha1 | ||
|
||
if echo $sha1 | grep pr | ||
then | ||
echo "No need to send as it is PR checks" | ||
else | ||
echo -e "Jenkins Randomized Gradle Check Build ${BUILD_NUMBER} Failed on ${sha1} `date`: \n${BUILD_URL} \n\nGitHub Issue: https://github.com/opensearch-project/OpenSearch/issues?q=is%3Aissue+is%3Aopen+Jenkins+Randomized+Gradle+Check" > SLACK_MSG.md | ||
SLACK_MSG=`cat SLACK_MSG.md` | ||
SLACK_DATA='{"Content":"'$SLACK_MSG'"}' | ||
|
||
curl -X POST -H 'Content-type: application/json' --data "$SLACK_DATA" ${SLACK_OPENSEARCH_CORE} | ||
|
||
|
||
MATCH_COUNTER=0 | ||
echo ISSUE_TITLE: $ISSUE_TITLE | ||
IFS=`echo -en "\n\b"` && for i in `curl -s https://api.github.com/repos/opensearch-project/OpenSearch/issues -H "Authorization: token $GITHUB_PASSWORD_CREDENTIAL" | jq -r .[].title`; | ||
do | ||
echo $i | ||
if echo $i | grep -qw "$ISSUE_TITLE"; | ||
then | ||
echo match | ||
MATCH_COUNTER=$((MATCH_COUNTER+1)) | ||
else | ||
echo not match | ||
fi | ||
done | ||
|
||
if [ "$MATCH_COUNTER" -eq 0 ]; then create_issue; fi | ||
|
||
|
||
fi |