Skip to content

Commit

Permalink
Pipeline template for capella addons
Browse files Browse the repository at this point in the history
This makes standard addon Jenkinsfiles very simple:

capellaAddon {
    url = <my addon git 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/<name>/zips/nightly/<versionFolder>
for update site and dropin zips.

download.eclipse.org/capella/addons/<name>/updates/nightly/<versionFolder>/<site-version>

where <versionFolder> 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 <[email protected]>
  • Loading branch information
felixdo committed Feb 19, 2020
1 parent e2f2570 commit e111668
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions vars/capellaAddon.groovy
Original file line number Diff line number Diff line change
@@ -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/<name>/
// * dropins and site zip name
//
// (optional) targetPlatform = <path-to-tp-pom>. Starts with capella-releng-parent/ or <name>/
// (optional) versionFolder = <folder-name>. By default, artifacts go to <name>/updates/nightly/<branch>
// 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
// <name>/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}\""
}
}
}
}
}
}
}

0 comments on commit e111668

Please sign in to comment.