Skip to content

Commit

Permalink
Consistently use BRANCH parameter for retrieving pipeline definition
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Hudalla <[email protected]>
  • Loading branch information
sophokles73 committed Dec 7, 2020
1 parent 98ad949 commit af0829b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
11 changes: 8 additions & 3 deletions jenkins/Hono-Deploy-Eclipse-Pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
node {
def utils = evaluate readTrusted("jenkins/Hono-PipelineUtils.groovy")
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '3')), parameters([
string(
name: 'BRANCH',
description: "The branch to read the pipeline definition from.\nExamples:\n refs/heads/master\nrefs/heads/1.3.x",
defaultValue: '',
trim: true),
string(
name: 'RELEASE_VERSION',
description: "The tag to build and deploy.\nExamples:\nrefs/tags/1.0.0-M6\nrefs/tags/1.0.0-RC1\nrefs/tags/2.1.0",
defaultValue: 'refs/tags/',
description: "The tag to build and deploy.\nExamples:\n1.0.0-M6\n1.0.0-RC1\n2.1.0",
defaultValue: '',
trim: true)
])])
try {
utils.checkOutRepoWithCredentials("${params.RELEASE_VERSION}", "github-bot-ssh", "ssh://[email protected]/eclipse/hono.git")
utils.checkOutRepoWithCredentials("refs/tags/${params.RELEASE_VERSION}", "github-bot-ssh", "ssh://[email protected]/eclipse/hono.git")
buildAndDeploy(utils)
currentBuild.result = 'SUCCESS'
} catch (err) {
Expand Down
11 changes: 8 additions & 3 deletions jenkins/Hono-Deploy-Maven-Central-Pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
node {
def utils = evaluate readTrusted("jenkins/Hono-PipelineUtils.groovy")
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '3')), parameters([
string(
name: 'BRANCH',
description: "The branch to read the pipeline definition from.\nExamples:\n refs/heads/master\nrefs/heads/1.3.x",
defaultValue: '',
trim: true),
string(
name: 'RELEASE_VERSION',
description: "The tag to build and deploy.\nExamples:\nrefs/tags/1.0.0-M6\nrefs/tags/1.0.0-RC1\nrefs/tags/2.1.0",
defaultValue: 'refs/tags/',
description: "The tag to build and deploy.\nExamples:\n1.0.0-M6\n1.0.0-RC1\n2.1.0",
defaultValue: '',
trim: true)
])])
try {
utils.checkOutRepoWithCredentials("${params.RELEASE_VERSION}", "github-bot-ssh", "ssh://[email protected]/eclipse/hono.git")
utils.checkOutRepoWithCredentials("refs/tags/${params.RELEASE_VERSION}", "github-bot-ssh", "ssh://[email protected]/eclipse/hono.git")
buildAndDeploy(utils)
currentBuild.result = 'SUCCESS'
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion jenkins/Hono-PipelineUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void checkOutHonoRepoMaster() {
*/
void checkOutRepoWithCredentials(String branch, String credentialsId, String url) {
stage('Checkout') {
echo "Check out branch: [$branch] from repository [$url] with provided credentials"
echo "Checking out branch [$branch] from repository [$url] with provided credentials"
checkout([$class : 'GitSCM',
branches : [[name: "$branch"]],
doGenerateSubmoduleConfigurations: false,
Expand Down
10 changes: 5 additions & 5 deletions jenkins/Hono-Release-Pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ node {
def utils = evaluate readTrusted("jenkins/Hono-PipelineUtils.groovy")
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '3')), parameters([
string(defaultValue: '',
description: "The branch to build and release from.\nExamples: \n master\n1.0.x\n1.x",
description: "The branch to build and release from.\nExamples:\n refs/heads/master\nrefs/heads/1.4.x",
name: 'BRANCH',
trim: true),
string(defaultValue: '',
description: "The version identifier to use for the artifacts built and released by this job. \nExamples:\n1.0.0-M6\n1.0.0-RC1\n2.1.0",
description: "The version identifier (tag name) to use for the artifacts built and released by this job. \nExamples:\n1.0.0-M6\n1.3.0-RC1\n1.4.4",
name: 'RELEASE_VERSION',
trim: true),
string(defaultValue: '',
description: "The version identifier to use during development of the next version.\nExamples:\n2.0.0-SNAPSHOT\n1.1.0-SNAPSHOT",
description: "The version identifier to use during development of the next version.\nExamples:\n2.0.0-SNAPSHOT\n1.6.0-SNAPSHOT",
name: 'NEXT_VERSION',
trim: true),
booleanParam(defaultValue: true,
Expand Down Expand Up @@ -64,9 +64,9 @@ node {
*/
def checkOut() {
stage('Checkout') {
echo "Check out branch: origin/${params.BRANCH}"
echo "Check out branch: ${params.BRANCH}"
checkout([$class : 'GitSCM',
branches : [[name: "origin/${params.BRANCH}"]],
branches : [[name: "${params.BRANCH}"]],
doGenerateSubmoduleConfigurations: false,
extensions : [[$class: 'WipeWorkspace'],
[$class: 'LocalBranch']],
Expand Down

0 comments on commit af0829b

Please sign in to comment.