Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvigodithi committed Jul 27, 2023
2 parents 70507a0 + 5b00d67 commit fff9207
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/groovy-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- name: Run Tests
run: |
./gradlew test --info --tests=TestCloseGithubIssue
./gradlew test --info
- name: Upload Coverage Report
uses: codecov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Jenkins workflow regression tests typically output a .txt file into [tests/jenki
For example, [TestHello.groovy](tests/jenkins/TestHello.groovy) executes [Hello_Jenkinsfile](tests/jenkins/jobs/Hello_Jenkinsfile)
and outputs [Hello_Jenkinsfile.txt](tests/jenkins/jobs/Hello_Jenkinsfile.txt). If the job execution changes, the regression test will fail.

- To update the recorded .txt file run `./gradlew test -info -Ppipeline.stack.write=true` or update its value in [gradle.properties](gradle.properties).
- To update the recorded .txt file run `./gradlew test -info -Dpipeline.stack.write=true` or update its value in [gradle.properties](gradle.properties).

- To run a specific test case, run `./gradlew test -info --tests=TestCaseClassName`

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ lib = library(identifier: 'jenkins@<tag>', retriever: modernSCM([
| [publishToNuget.groovy](./vars/publishToNuget.groovy) | A library to build, sign and publish dotnet artifacts to [Nuget Gallery](https://www.nuget.org/). Please check if the [default docker](https://github.com/opensearch-project/opensearch-build/blob/main/docker/ci/dockerfiles/current/release.centos.clients.x64.arm64.dockerfile) file contains the required dotnet sdk. You can use [PublishToNugetLibTester](./tests/jenkins/lib-testers/PublishToNugetLibTester.groovy) to add tests in your repository. See how to use the lib in your [jenkinsFile](./tests/jenkins/jobs/PublishToNuget_Jenkinsfile).
| [publishToArtifactsProdBucket.groovy](./vars/publishToArtifactsProdBucket.groovy) | This library signs and uploads the artifacts to production S3 bucket which points to artifacts.opensearch.org. Please make sure the role that you use to upload exists and has the right permission. For artifacts of different types like macos, linux and windows, call this lib for each artifact with different signing parameters. You can use [PublishToArtifactsProdBucketLibTester](./tests/jenkins/lib-testers/PublishToArtifactsProdBucketLibTester.groovy) to add tests in your repository. See how to use the lib in your [jenkinsFile](./tests/jenkins/jobs/PublishToArtifactsProdBucket_Jenkinsfile).

| [buildMessage.groovy](./vars/buildMessage.groovy) | This library that can parse the jenkins build log based based on the user passsed input query string.
| [closeBuildSuccessGithubIssue.groovy](./vars/closeBuildSuccessGithubIssue.groovy) | This library that identifies the successfully built components and closes the created [AUTOCUT] issues.
| [createGithubIssue.groovy](./vars/createGithubIssue.groovy) | This library that identifies the failed components and creates the [AUTOCUT] issues.

## Contributing

See [developer guide](DEVELOPER_GUIDE.md) and [how to contribute to this project](CONTRIBUTING.md).
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/TestCloseBuildSuccessGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TestCloseBuildSuccessGithubIssue extends BuildPipelineTest {

@Test
public void testExistingGithubIssue() {
super.testPipeline('tests/jenkins/jobs/CloseBuildSuccessGithubIssue_Jenkinsfile')
super.testPipeline('tests/jenkins/jobs/CloseBuildSuccessGithubIssue_JenkinsFile')
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S \"[AUTOCUT] Distribution Build Failed for OpenSearch-2.0.0 in:title\" --label autocut,v2.0.0 --json number --jq '.[0].number', returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/OpenSearch --comment \"Closing the issue as the distribution build for OpenSearch has passed for version: **2.0.0**.\n Please see build log at www.example.com/jobs/test/123/consoleFull\", returnStdout=true}"))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/jenkins/TestCloseGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class TestCloseGithubIssue extends BuildPipelineTest {
'label101',
))
super.testPipeline("tests/jenkins/jobs/CloseGithubIssue_JenkinsFile")
// assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/opensearch-build -S \"Test GH issue title in:title\" --label label101 --json number --jq '.[0].number', returnStdout=true}"))
// assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/opensearch-build --comment \"Test GH issue close comment\", returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/opensearch-build -S \"Test GH issue title in:title\" --label label101 --json number --jq '.[0].number', returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/opensearch-build --comment \"Test GH issue close comment\", returnStdout=true}"))
}

def getCommands(method, text) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CloseBuildSuccessGithubIssue_Jenkinsfile.run()
CloseBuildSuccessGithubIssue_Jenkinsfile.pipeline(groovy.lang.Closure)
CloseBuildSuccessGithubIssue_Jenkinsfile.echo(Executing on agent [label:none])
CloseBuildSuccessGithubIssue_Jenkinsfile.stage(notify, groovy.lang.Closure)
CloseBuildSuccessGithubIssue_Jenkinsfile.script(groovy.lang.Closure)
CloseBuildSuccessGithubIssue_Jenkinsfile.closeBuildSuccessGithubIssue({message=[Build successful OpenSearch], inputManifestPath=tests/data/opensearch-2.0.0.yml})
CloseBuildSuccessGithubIssue_JenkinsFile.run()
CloseBuildSuccessGithubIssue_JenkinsFile.pipeline(groovy.lang.Closure)
CloseBuildSuccessGithubIssue_JenkinsFile.echo(Executing on agent [label:none])
CloseBuildSuccessGithubIssue_JenkinsFile.stage(notify, groovy.lang.Closure)
CloseBuildSuccessGithubIssue_JenkinsFile.script(groovy.lang.Closure)
CloseBuildSuccessGithubIssue_JenkinsFile.closeBuildSuccessGithubIssue({message=[Build successful OpenSearch], inputManifestPath=tests/data/opensearch-2.0.0.yml})
closeBuildSuccessGithubIssue.legacySCM(groovy.lang.Closure)
closeBuildSuccessGithubIssue.library({identifier=jenkins@main, retriever=null})
closeBuildSuccessGithubIssue.readYaml({file=tests/data/opensearch-2.0.0.yml})
Expand Down
4 changes: 2 additions & 2 deletions tests/jenkins/jobs/RunGradleCheck_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
./gradlew --stop
rm -rf ~/.gradle

if ! (uname -s | grep -i NT); then
if command -v docker > /dev/null; then
echo "Check existing dockercontainer"
docker ps -a
docker stop `docker ps -qa` > /dev/null 2>&1 || echo
docker rm `docker ps -qa` > /dev/null 2>&1 || echo
docker rm --force `docker ps -qa` > /dev/null 2>&1 || echo
echo "Stop existing dockercontainer"
docker ps -a

Expand Down
11 changes: 3 additions & 8 deletions vars/buildMessage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ import com.cloudbees.groovy.cps.NonCPS
import org.apache.commons.io.IOUtils
@NonCPS
def call(Map args = [:]){
String QUERY_STRING = ''
if (args.search == 'fail') {
QUERY_STRING = "Error building"
} else if (args.search == 'pass') {
QUERY_STRING = "Build successful"
}
String QUERY_STRING = args.search
List<String> message = []
Reader performance_log = currentBuild.getRawBuild().getLogReader()
String logContent = IOUtils.toString(performance_log)
performance_log.close()
performance_log = null
logContent.eachLine() { line ->
line=line.replace("\"", "")
//Gets the exact match for Error building
//Gets the exact match of the log starting with args.search
def java.util.regex.Matcher match = (line =~ /$QUERY_STRING.*/)
if (match.find()) {
line=match[0]
Expand All @@ -36,7 +31,7 @@ def call(Map args = [:]){
}
//if no match returns as Build failed
if(message.isEmpty()){
message=["Build failed"]
message=["The search QUERY_STRING not identified in build log"]
}
return message
}
2 changes: 1 addition & 1 deletion vars/closeGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void call(Map args = [:]) {
returnStdout: true
)
} else {
println("No open distribution failure AUTOCUT issues to close for the repo ${args.repoUrl}")
println("No open distribution failure AUTOCUT issues found that needs to be closed for the repo ${args.repoUrl}")
}
}
} catch (Exception ex) {
Expand Down
4 changes: 2 additions & 2 deletions vars/runGradleCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ void call(Map args = [:]) {
./gradlew --stop
rm -rf ~/.gradle
if ! (uname -s | grep -i NT); then
if command -v docker > /dev/null; then
echo "Check existing dockercontainer"
docker ps -a
docker stop `docker ps -qa` > /dev/null 2>&1 || echo
docker rm `docker ps -qa` > /dev/null 2>&1 || echo
docker rm --force `docker ps -qa` > /dev/null 2>&1 || echo
echo "Stop existing dockercontainer"
docker ps -a
Expand Down

0 comments on commit fff9207

Please sign in to comment.