Skip to content

Commit

Permalink
Add release-chores workflow (#5325)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya authored Feb 18, 2025
1 parent e4e7a80 commit 4fb0a6a
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
69 changes: 69 additions & 0 deletions jenkins/release-workflows/release-chores.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright OpenSearch Contributors
* 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.
*/

lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))

pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent {
docker {
label 'Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:ci-runner-al2-opensearch-build-v1'
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
parameters {
string(
name: 'RELEASE_VERSION',
description: "Required: On-going release version, e.g. 2.0.0",
trim: true
)
string(
name: 'RELEASE_CHORE',
description: "Required: What release chore you wanna do? e.g: 'add_rc_details_comment'",
trim: true
)
}
stages {
stage('Parameter check') {
steps {
script {
if (!(params.RELEASE_VERSION && params.RELEASE_CHORE)) {
error('Required parameters are missing. Please provide the mandatory arguments RELEASE_VERSION and RELEASE_CHORE')
}
}
}
}
stage('Add RC details and Docker Scan comment') {
when {
expression { params.RELEASE_CHORE == 'add_rc_details_comment' }
}
steps {
script {
addRcDetailsComment(
version: "${params.RELEASE_VERSION}"
)
}
}
}
}
post() {
always {
script {
postCleanup()
}
}
}
}
61 changes: 61 additions & 0 deletions tests/jenkins/TestReleaseChores.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright OpenSearch Contributors
* 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

import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.MatcherAssert.assertThat

import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.GitSource.gitSource

class TestReleaseChores extends BuildPipelineTest {

@Override
@Before
void setUp() {
helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('8.2.0')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
.retriever(gitSource('https://github.com/opensearch-project/opensearch-build-libraries.git'))
.build()
)

super.setUp()
}

@Test
public void testVerifyParameters() {
addParam('RELEASE_VERSION', '')
addParam('RELEASE_CHORE', 'add_rc_details_comment')
runScript('jenkins/release-workflows/release-chores.jenkinsfile')
assertThat(getCommandExecutions('error', ''), hasItem('Required parameters are missing. Please provide the mandatory arguments RELEASE_VERSION and RELEASE_CHORE'))
}

def getCommandExecutions(methodName, command) {
def shCommands = helper.callStack.findAll {
call ->
call.methodName == methodName
}.
collect {
call ->
callArgsToString(call)
}.findAll {
shCommand ->
shCommand.contains(command)
}
return shCommands
}
}

0 comments on commit 4fb0a6a

Please sign in to comment.