Skip to content

Commit

Permalink
test release brance ref
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
Divyaasm committed Jan 30, 2025
1 parent a20a89d commit a431814
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions jenkins/release-workflows/release-manifest-commit-lock.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ pipeline {
trim: true
)
choice(
choices: ['MATCH_BUILD_MANIFEST', 'UPDATE_TO_RECENT_COMMITS', 'UPDATE_TO_TAGS'],
choices: ['MATCH_BUILD_MANIFEST', 'UPDATE_TO_RECENT_COMMITS', 'UPDATE_TO_TAGS', 'UPDATE_TO_RELEASE_BRANCH'],
name: 'MANIFEST_LOCK_ACTION',
description: 'The manifest lock action to choose.<br>MATCH_BUILD_MANIFEST: Will update the manifest with commit ID from release candidate build manifest.<br>UPDATE_TO_RECENT_COMMITS: Will update the manifest with component repo release branch head commit.<br>UPDATE_TO_TAGS: Will update the manifest with ref tags',
description: 'The manifest lock action to choose.<br>MATCH_BUILD_MANIFEST: Will update the manifest with commit ID from release candidate build manifest.<br>UPDATE_TO_RECENT_COMMITS: Will update the manifest with component repo release branch head commit.<br>UPDATE_TO_TAGS: Will update the manifest with ref tags.<br>UPDATE_TO_RELEASE_BRANCH: Will update the manifest ref with release branch',
)
string(
name: 'COMPONENTS',
Expand Down Expand Up @@ -176,15 +176,44 @@ pipeline {
}
}
}
stage('UPDATE_TO_RELEASE_BRANCH') {
when {
expression { params.MANIFEST_LOCK_ACTION == 'UPDATE_TO_RELEASE_BRANCH' }
}
steps {
script {
def updateManifest = { String productName ->
def existingManifest = readYaml file: "manifests/${params.RELEASE_VERSION}/${productName}-${params.RELEASE_VERSION}.yml"
def selectedComponents = params.COMPONENTS.isEmpty() ? existingManifest.components : existingManifest.components.findAll { component ->
params.COMPONENTS.split(',').any { it.trim() == component.name }
}
selectedComponents.each { componentName ->
def existingComponent = existingManifest.components.find { it.name == componentName.name }
if (existingComponent) {
def branchRef = RELEASE_VERSION.split('\\.')[0..1].join('.')
existingComponent.ref = "'" + releaseTag + "'"
}
}
writeYaml file: "manifests/${params.RELEASE_VERSION}/${productName}-${params.RELEASE_VERSION}.yml", data: existingManifest, overwrite: true
sh """
yq eval -i '.' manifests/${params.RELEASE_VERSION}/${productName}-${params.RELEASE_VERSION}.yml
sed -i '1s/^/---\\n/' manifests/${params.RELEASE_VERSION}/${productName}-${params.RELEASE_VERSION}.yml
"""
}
updateManifest("opensearch")
updateManifest("opensearch-dashboards")
}
}
}
stage('Create Pull Request') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', passwordVariable: 'GITHUB_TOKEN', usernameVariable: 'GITHUB_USER')]) {
try {
sh """
git remote set-url origin "https://opensearch-ci:${GITHUB_TOKEN}@github.com/opensearch-project/opensearch-build"
git config user.email "opensearch-infra@amazon.com"
git config user.name "opensearch-ci"
git remote set-url origin "https://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@github.com/Divyaasm/opensearch-build.git
git config user.email "divyaasm@amazon.com"
git config user.name "Divyaasm"
git checkout -b manifest-lock
"""
def status = sh(returnStdout: true, script: 'git status --porcelain')
Expand Down

0 comments on commit a431814

Please sign in to comment.