diff --git a/.ci-orchestrator/build.yml b/.ci-orchestrator/build.yml new file mode 100644 index 00000000..6d5e503e --- /dev/null +++ b/.ci-orchestrator/build.yml @@ -0,0 +1,27 @@ +type: pipeline_definition +product: Liberty +name: CiCommon +description: Run a Pipeline for ci.common using Cognitive Software Delivery infrastructure + +triggers: +- type: manual + triggerName: "Manual" + description: "Runs a ci.common Pipeline, building and testing the PR - Manual Trigger" + triggerRank: 50 + groups: ["CommonComponents"] +- type: github + triggerName: "GitHub" + description: "Runs a ci.common Pipeline, building and testing the PR - Github Trigger" + triggerRank: 50 + groups: ["CommonComponents"] + keyword: "!build" + aliasKeywords: + - "#build" + +steps: +- stepGroup: Build ci.common Dependency + includeSteps: + - file: steps/buildCiCommonDependency.yml +- stepGroup: Build ci.common + includeSteps: + - file: steps/buildCiCommon.yml diff --git a/.ci-orchestrator/steps/buildCiCommon.yml b/.ci-orchestrator/steps/buildCiCommon.yml new file mode 100644 index 00000000..5586d2a7 --- /dev/null +++ b/.ci-orchestrator/steps/buildCiCommon.yml @@ -0,0 +1,10 @@ +- stepName: "CiCommonBuild" + coreStep: true + workType: Jenkins + projectName: CiCommonBuild + timeoutInMinutes: 30 + dependsOn: + - stepName: CiCommonDependencyBuild + awaitOutputProperties: true + properties: + jenkinsServiceName: "websphere-extra-jenkins" diff --git a/.ci-orchestrator/steps/buildCiCommonDependency.yml b/.ci-orchestrator/steps/buildCiCommonDependency.yml new file mode 100644 index 00000000..4b69d86a --- /dev/null +++ b/.ci-orchestrator/steps/buildCiCommonDependency.yml @@ -0,0 +1,7 @@ +- stepName: "CiCommonDependencyBuild" + coreStep: true + workType: Jenkins + projectName: CiCommonDependencyBuild + timeoutInMinutes: 30 + properties: + jenkinsServiceName: "websphere-extra-jenkins" diff --git a/jenkins/build.jenkinsfile b/jenkins/build.jenkinsfile new file mode 100644 index 00000000..ce7f8f05 --- /dev/null +++ b/jenkins/build.jenkinsfile @@ -0,0 +1,38 @@ +properties([ + parameters([ + string(name: 'executionId', defaultValue: UUID.randomUUID().toString(), description: 'Unique execution id.'), + string(name: 'ebcPlan', defaultValue: 'See Shortlist', description: 'EBC plan to use when provisioning a Jenkins node (ignored when shortlist is supplied).'), + string(name: 'ebcShortlist', defaultValue: 'jenkins-child.yml', description: 'Overrides the ebcPlan. This controls the EBC shortlist to use when provisioning a Jenkins node.'), + string(name: 'github_pr_branch', defaultValue: "main", description: 'Git branch to check out of repo. If the branch does not exist, main is used instead.') + ]) +]) +timestamps { + library 'jenkins-ci-websphere' + if (shouldSkipDueToSeedJob()) { + return; + } + + try { + onEBC( + demandId: params.executionId, + ebcPlan: params.ebcPlan, + ebcShortlist: params.ebcShortlist, + autoCompleteAfterXHours: 24) { + buildName params.executionId + stage("Running Job") { + reportActivity(name: "ci.common PR Build", executionId: params.executionId) { + sh "git clone --branch ${params.github_pr_branch} --depth 1 https://github.com/OpenLiberty/ci.common.git ci.common" + withEnv([ + "executionId=${params.executionId}" + ]) { + sh "ci.common/scripts/build.sh" + } + } + } + } + } finally { + onLocal() { + cleanupWorkspace() + } + } +} diff --git a/jenkins/buildDependency.jenkinsfile b/jenkins/buildDependency.jenkinsfile new file mode 100644 index 00000000..e1577e33 --- /dev/null +++ b/jenkins/buildDependency.jenkinsfile @@ -0,0 +1,38 @@ +properties([ + parameters([ + string(name: 'executionId', defaultValue: UUID.randomUUID().toString(), description: 'Unique execution id.'), + string(name: 'ebcPlan', defaultValue: 'See Shortlist', description: 'EBC plan to use when provisioning a Jenkins node (ignored when shortlist is supplied).'), + string(name: 'ebcShortlist', defaultValue: 'jenkins-child.yml', description: 'Overrides the ebcPlan. This controls the EBC shortlist to use when provisioning a Jenkins node.'), + string(name: 'github_pr_branch', defaultValue: "main", description: 'Git branch to check out of repo. If the branch does not exist, main is used instead.') + ]) +]) +timestamps { + library 'jenkins-ci-websphere' + if (shouldSkipDueToSeedJob()) { + return; + } + + try { + onEBC( + demandId: params.executionId, + ebcPlan: params.ebcPlan, + ebcShortlist: params.ebcShortlist, + autoCompleteAfterXHours: 24) { + buildName params.executionId + stage("Running Job") { + reportActivity(name: "ci.common Dependency Build", executionId: params.executionId) { + sh "git clone --branch ${params.github_pr_branch} --depth 1 https://github.com/OpenLiberty/ci.common.git ci.common" + withEnv([ + "executionId=${params.executionId}" + ]) { + sh "ci.common/scripts/buildDependency.sh" + } + } + } + } + } finally { + onLocal() { + cleanupWorkspace() + } + } +} diff --git a/jenkins/jobs/build.groovy b/jenkins/jobs/build.groovy new file mode 100644 index 00000000..c378b90f --- /dev/null +++ b/jenkins/jobs/build.groovy @@ -0,0 +1,20 @@ +pipelineJob("CiCommonBuild") { + description("Builds ci.common.") + keepDependencies(false) + definition { + cpsScm { + scm { + git("https://github.com/OpenLiberty/ci.common.git", "main") + } + scriptPath("jenkins/build.jenkinsfile") + lightweight() + } + } + disabled(false) + configure { + it / 'properties' / 'com.sonyericsson.rebuild.RebuildSettings' { + 'autoRebuild'('false') + 'rebuildDisabled'('false') + } + } +} diff --git a/jenkins/jobs/buildDependency.groovy b/jenkins/jobs/buildDependency.groovy new file mode 100644 index 00000000..d774976f --- /dev/null +++ b/jenkins/jobs/buildDependency.groovy @@ -0,0 +1,20 @@ +pipelineJob("CiCommonDependencyBuild") { + description("Builds ci.common dependency.") + keepDependencies(false) + definition { + cpsScm { + scm { + git("https://github.com/OpenLiberty/ci.common.git", "main") + } + scriptPath("jenkins/buildDependency.jenkinsfile") + lightweight() + } + } + disabled(false) + configure { + it / 'properties' / 'com.sonyericsson.rebuild.RebuildSettings' { + 'autoRebuild'('false') + 'rebuildDisabled'('false') + } + } +} diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 00000000..8318b41b --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo "=== ci.common build.sh ===" +echo "executionId: ${executionId}" diff --git a/scripts/buildDependency.sh b/scripts/buildDependency.sh new file mode 100644 index 00000000..f7fd2d3b --- /dev/null +++ b/scripts/buildDependency.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo "=== ci.common buildDependency.sh ===" +echo "executionId: ${executionId}"