-
Notifications
You must be signed in to change notification settings - Fork 282
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: Sayali Gaikawad <[email protected]>
- Loading branch information
Showing
2 changed files
with
130 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,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() | ||
} | ||
} | ||
} | ||
} |
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,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 | ||
} | ||
} |