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}\"" + } + } + } + } + } + } +}