From e1116681441128034955ca1be6afa68dbb48f0d3 Mon Sep 17 00:00:00 2001 From: Felix Dorner Date: Thu, 6 Feb 2020 14:46:26 +0100 Subject: [PATCH] Pipeline template for capella addons This makes standard addon Jenkinsfiles very simple: capellaAddon { url = name = 'MyAddon' targetPlatform = "MyAddon/my/targetplatform/pom.xml" versionFolder = 'some-custom-folder' } Optional parameters are: ======================== targetPlatform: if not present, the build will use a default addon targetplatform versionFolder: defaults to the name of the branch being built. can be used to redirect master branch artifacts to the upcoming capella version (see below) The 'name' parameter will be used to for 3 things: ================================================== dropins zip filename update site zip filename download path segment for artifacts (see below) Deployment ========== It is expected that the build produces a single dropins zip and a single update site + update site zip. These zipfiles are located by searching for category.xml. The artifacts (updatesite, updatesite zip, dropins zip) are then copied to download.eclipse.org/capella/addons//zips/nightly/ for update site and dropin zips. download.eclipse.org/capella/addons//updates/nightly// where defaults to the branch name. On master branches this should be overwritten in Jenkinsfile, using the capella version that the master branch currently targets. Signed-off-by: Felix Dorner --- vars/capellaAddon.groovy | 95 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 vars/capellaAddon.groovy diff --git a/vars/capellaAddon.groovy b/vars/capellaAddon.groovy new file mode 100644 index 0000000..440e9c3 --- /dev/null +++ b/vars/capellaAddon.groovy @@ -0,0 +1,95 @@ +def call(body) { + + // Jenkinsfile: + // capellaAddon { + // url = "git repo url" // where the git clone comes from + // name = "addon-name" // name will be used for: + // * download folder name: download.eclipse.org/capella/addons// + // * dropins and site zip name + // + // (optional) targetPlatform = . Starts with capella-releng-parent/ or / + // (optional) versionFolder = . By default, artifacts go to /updates/nightly/ + // but we want to avoid using 'master' as a folder name, so in your master branch + // you can e.g. set this to 'v1.5.x' to copy artifacts to + // /updates/nightly/v1.5.x/. + // }. + + def pipelineParams= [targetPlatform: 'capella-releng-parent/tp/capella-default-addon-target/pom.xml', + versionFolder: env.BRANCH_NAME + ] + + body.resolveStrategy = Closure.DELEGATE_FIRST + body.delegate = pipelineParams + body() + + + pipeline { + + // dont checkout into the root folder, we use 2 subfolders, one for the addon, one for the capella-releng-parent + options { skipDefaultCheckout() } + + agent { + label "migration" + } + + tools { + maven "apache-maven-latest" + jdk "oracle-jdk8-latest" + } + + stages { + + // TODO: For PR branches, the releng branch must be the branch + // that is targeted by the PR, e.g. a PR for 1.3 should use the 1.3 releng branch + stage ('Fail for pull requests'){ + when { changeRequest() } + steps { + error("Cannot build pull requests (yet)") + } + } + + stage ('Checkout capella-releng-parent & addon code') { + steps { + + checkout([$class: 'GitSCM', + branches: [[name: "*/${env.BRANCH_NAME}"]], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'RelativeTargetDirectory', + relativeTargetDir: pipelineParams.name]], + submoduleCfg: [], userRemoteConfigs: [[url: pipelineParams.url]]]) + + + checkout([$class: 'GitSCM', + branches: [[name: "*/${env.BRANCH_NAME}"]], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'RelativeTargetDirectory', + relativeTargetDir: 'capella-releng-parent']], + submoduleCfg: [], + userRemoteConfigs: [[url: 'https://github.com/eclipse/capella-releng-parent.git']]]) + } + } + + stage ('Generate Targetplatform'){ + steps { + sh "mvn --batch-mode --activate-profiles generate-target -f \"${pipelineParams.targetPlatform}\" clean install" + } + } + stage ('Build') { + steps { + sh "mvn --batch-mode -DpackagedSiteName=\"${pipelineParams.name}\" -f \"${pipelineParams.name}/pom.xml\" clean verify" + } + } + + + stage ('Publish Nightly'){ + steps { + dir (pipelineParams.name) { + sshagent (['projects-storage.eclipse.org-bot-ssh']) { + sh "../capella-releng-parent/scripts/deployAddonNightly.sh -n \"${pipelineParams.name}\" -b \"${pipelineParams.versionFolder}\"" + } + } + } + } + } + } +}