Skip to content

Commit 4fb0a6a

Browse files
authored
Add release-chores workflow (#5325)
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
1 parent e4e7a80 commit 4fb0a6a

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
lib = library(identifier: 'jenkins@8.2.0', retriever: modernSCM([
11+
$class: 'GitSCMSource',
12+
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
13+
]))
14+
15+
pipeline {
16+
options {
17+
timeout(time: 1, unit: 'HOURS')
18+
}
19+
agent {
20+
docker {
21+
label 'Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host'
22+
image 'opensearchstaging/ci-runner:ci-runner-al2-opensearch-build-v1'
23+
registryUrl 'https://public.ecr.aws/'
24+
alwaysPull true
25+
}
26+
}
27+
parameters {
28+
string(
29+
name: 'RELEASE_VERSION',
30+
description: "Required: On-going release version, e.g. 2.0.0",
31+
trim: true
32+
)
33+
string(
34+
name: 'RELEASE_CHORE',
35+
description: "Required: What release chore you wanna do? e.g: 'add_rc_details_comment'",
36+
trim: true
37+
)
38+
}
39+
stages {
40+
stage('Parameter check') {
41+
steps {
42+
script {
43+
if (!(params.RELEASE_VERSION && params.RELEASE_CHORE)) {
44+
error('Required parameters are missing. Please provide the mandatory arguments RELEASE_VERSION and RELEASE_CHORE')
45+
}
46+
}
47+
}
48+
}
49+
stage('Add RC details and Docker Scan comment') {
50+
when {
51+
expression { params.RELEASE_CHORE == 'add_rc_details_comment' }
52+
}
53+
steps {
54+
script {
55+
addRcDetailsComment(
56+
version: "${params.RELEASE_VERSION}"
57+
)
58+
}
59+
}
60+
}
61+
}
62+
post() {
63+
always {
64+
script {
65+
postCleanup()
66+
}
67+
}
68+
}
69+
}
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
import jenkins.tests.BuildPipelineTest
11+
import org.junit.Before
12+
import org.junit.Test
13+
14+
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
15+
import static org.hamcrest.CoreMatchers.hasItem
16+
import static org.hamcrest.MatcherAssert.assertThat
17+
18+
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
19+
import static com.lesfurets.jenkins.unit.global.lib.GitSource.gitSource
20+
21+
class TestReleaseChores extends BuildPipelineTest {
22+
23+
@Override
24+
@Before
25+
void setUp() {
26+
helper.registerSharedLibrary(
27+
library().name('jenkins')
28+
.defaultVersion('8.2.0')
29+
.allowOverride(true)
30+
.implicit(true)
31+
.targetPath('vars')
32+
.retriever(gitSource('https://github.com/opensearch-project/opensearch-build-libraries.git'))
33+
.build()
34+
)
35+
36+
super.setUp()
37+
}
38+
39+
@Test
40+
public void testVerifyParameters() {
41+
addParam('RELEASE_VERSION', '')
42+
addParam('RELEASE_CHORE', 'add_rc_details_comment')
43+
runScript('jenkins/release-workflows/release-chores.jenkinsfile')
44+
assertThat(getCommandExecutions('error', ''), hasItem('Required parameters are missing. Please provide the mandatory arguments RELEASE_VERSION and RELEASE_CHORE'))
45+
}
46+
47+
def getCommandExecutions(methodName, command) {
48+
def shCommands = helper.callStack.findAll {
49+
call ->
50+
call.methodName == methodName
51+
}.
52+
collect {
53+
call ->
54+
callArgsToString(call)
55+
}.findAll {
56+
shCommand ->
57+
shCommand.contains(command)
58+
}
59+
return shCommands
60+
}
61+
}

0 commit comments

Comments
 (0)