From c077f9cc05a9d3f440721f177da2f08b491c24df Mon Sep 17 00:00:00 2001 From: Yahav Itzhak Date: Tue, 28 Nov 2023 17:04:32 +0200 Subject: [PATCH] Synchronize branches on release (#2328) --- Jenkinsfile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c5f2e9671..4dd0944af 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,6 +46,18 @@ node("docker") { } } + state('synchronize branches') { + if ("$EXECUTION_MODE".toString().equals("Build CLI")) { + masterBranch = 'v2' + devBranch = 'dev' + if (BRANCH?.trim() == 'v1') { + masterBranch = 'v1' + devBranch = 'dev-v1' + } + synchronizeBranches(masterBranch, devBranch) + } + } + stage('install npm') { installNpm(nodeVersion) } @@ -148,6 +160,28 @@ def runRelease(architectures) { } } +def synchronizeBranches(masterBranch, devBranch) { + dir("$cliWorkspace/$repo") { + releaseTag = "v$RELEASE_VERSION" + withCredentials([string(credentialsId: 'ecosystem-github-automation', variable: 'GITHUB_ACCESS_TOKEN')]) { + stage("Merge to $masterBranch") { + sh """#!/bin/bash + git merge origin/$devBranch --no-edit + git push "https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git" + """ + } + stage("Merge to $devBranch") { + sh """#!/bin/bash + git checkout $devBranch + git merge origin/$masterBranch --no-edit + git push "https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git" + git checkout $masterBranch + """ + } + } + } +} + def createTag() { stage('Create a tag and a GitHub release') { dir("$jfrogCliRepoDir") {