Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins library to generate buildInfo.yml #2473

Merged
merged 6 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pipeline {
}
}
}
stage('Get Repository Commits') {
stage('Initialize the job info yaml report') {
agent {
docker {
label AGENT_X64
Expand All @@ -75,16 +75,16 @@ pipeline {
}
steps {
script {
getRepositoryCommit(
componentName: "${COMPONENT_NAME}",
inputManifest: "manifests/${INPUT_MANIFEST}",
outputFile: "commits.yml"
buildInfoYaml(
componentName: COMPONENT_NAME,
inputManifest: "manifests/$INPUT_MANIFEST",
status: "NOT_STARTED",
stage: "INITIALIZE_STAGE"
)
}
}
post {
always {
archiveArtifacts artifacts: 'commits.yml'
postCleanup()
}
}
Expand Down Expand Up @@ -132,6 +132,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_X64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: integTestResults.getId(),
stage: "integ_test_x64"
)

env.ARTIFACT_URL_X64_TAR_INTEG_TEST_RESULT = createTestResultsMessage(
testType: "Integ Tests (x64, tar)",
status: integTestResults.getResult(),
Expand All @@ -153,6 +159,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_X64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: bwcTestResults.getId(),
stage: "bwc_test_x64"
)

env.ARTIFACT_URL_X64_TAR_BWC_TEST_RESULT = createTestResultsMessage(
testType: "BWC Tests (x64, tar)",
status: bwcTestResults.getResult(),
Expand Down Expand Up @@ -339,6 +351,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_ARM64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: integTestResults.getId(),
stage: "integ_test_arm64"
)

env.ARTIFACT_URL_ARM64_TAR_INTEG_TEST_RESULT = createTestResultsMessage(
testType: "Integ Tests (arm64, tar)",
status: integTestResults.getResult(),
Expand All @@ -360,6 +378,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_ARM64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: bwcTestResults.getId(),
stage: "bwc_test_arm64"
)

env.ARTIFACT_URL_ARM64_TAR_BWC_TEST_RESULT = createTestResultsMessage(
testType: "BWC Tests (arm64, tar)",
status: bwcTestResults.getResult(),
Expand Down Expand Up @@ -527,6 +551,20 @@ pipeline {
}
}
post {
always {
node(AGENT_X64) {
script {
buildInfoYaml(
componentName: COMPONENT_NAME,
status: currentBuild.result,
stage: "FINALIZE_STAGE"
)
unstash "buildInfo_yml"
archiveArtifacts artifacts: 'buildInfo.yml'
postCleanup()
}
}
}
success {
node(AGENT_X64) {
script {
Expand Down
50 changes: 44 additions & 6 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pipeline {
}
}
}
stage('Get Repository Commits') {
stage('Initialize the job info yaml report') {
agent {
docker {
label AGENT_X64
Expand All @@ -75,16 +75,16 @@ pipeline {
}
steps {
script {
getRepositoryCommit(
componentName: "${COMPONENT_NAME}",
inputManifest: "manifests/${INPUT_MANIFEST}",
outputFile: "commits.yml"
buildInfoYaml(
componentName: COMPONENT_NAME,
inputManifest: "manifests/$INPUT_MANIFEST",
status: "NOT_STARTED",
stage: "INITIALIZE_STAGE"
)
}
}
post {
always {
archiveArtifacts artifacts: 'commits.yml'
postCleanup()
}
}
Expand Down Expand Up @@ -233,6 +233,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_X64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: integTestResults.getId(),
stage: "integ_test_x64"
)

env.ARTIFACT_URL_X64_TAR_INTEG_TEST_RESULT = createTestResultsMessage(
testType: "Integ Tests (x64, tar)",
status: integTestResults.getResult(),
Expand All @@ -254,6 +260,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_X64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: bwcTestResults.getId(),
stage: "bwc_test_x64"
)

env.ARTIFACT_URL_X64_TAR_BWC_TEST_RESULT = createTestResultsMessage(
testType: "BWC Tests (x64, tar)",
status: bwcTestResults.getResult(),
Expand Down Expand Up @@ -407,6 +419,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_ARM64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: integTestResults.getId(),
stage: "integ_test_arm64"
)

env.ARTIFACT_URL_ARM64_TAR_INTEG_TEST_RESULT = createTestResultsMessage(
testType: "Integ Tests (arm64, tar)",
status: integTestResults.getResult(),
Expand All @@ -428,6 +446,12 @@ pipeline {
string(name: 'AGENT_LABEL', value: AGENT_ARM64)
]

buildInfoYaml(
componentName: COMPONENT_NAME,
status: bwcTestResults.getId(),
stage: "bwc_test_arm64"
)

env.ARTIFACT_URL_ARM64_TAR_BWC_TEST_RESULT = createTestResultsMessage(
testType: "BWC Tests (arm64, tar)",
status: bwcTestResults.getResult(),
Expand Down Expand Up @@ -594,6 +618,20 @@ pipeline {
}
}
post {
always {
node(AGENT_X64) {
script {
buildInfoYaml(
componentName: COMPONENT_NAME,
status: currentBuild.result,
stage: "FINALIZE_STAGE"
)
unstash "buildInfo_yml"
archiveArtifacts artifacts: 'buildInfo.yml'
postCleanup()
}
}
}
success {
node(AGENT_X64) {
script {
Expand Down
33 changes: 33 additions & 0 deletions tests/jenkins/TestBuildInfoYaml.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test


class TestBuildInfoYaml extends BuildPipelineTest {

@Before
void setUp() {
this.registerLibTester(new BuildInfoYamlLibTester(
'',
'tests/jenkins/data/opensearch-2.2.0.yml',
'tests/jenkins/data/buildInfo.yml',
'NOT_STARTED',
'INITIALIZE_STAGE'
)
)
super.setUp()
}

@Test
void testBuildInfoYaml() {
super.testPipeline("tests/jenkins/jobs/BuildInfoYaml_Jenkinsfile")
}
}
31 changes: 0 additions & 31 deletions tests/jenkins/TestGetRepositoryCommit.groovy

This file was deleted.

Loading