Discussion:
[nx-pub] nuxeo-openshift: NXCT-147: Add OpenshiftBuilder lib to build. tag, deploy image (branch@NXCT-147-openshift-builder-library)
Estelle Giuly
2018-12-11 09:26:58 UTC
Permalink
Message:
NXCT-147: Add OpenshiftBuilder lib to build. tag, deploy image

Repository: nuxeo-openshift
Branch: NXCT-147-openshift-builder-library
Author: Estelle Giuly <***@nuxeo.com>
Date: 2018-12-11T09:26:49 UTC
URL: https://github.com/nuxeo/nuxeo-openshift/commit/b8e8603dd3654eb55fbd17bc53e505d6d7c2ee0d
JIRA: https://jira.nuxeo.com/browse/NXCT-147

Files:
A src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy
M jenkinsfile/Jenkinsfile-build
M jenkinsfile/Jenkinsfile-release
M jenkinsfile/Jenkinsfile-single
M src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy

diff --git a/jenkinsfile/Jenkinsfile-build b/jenkinsfile/Jenkinsfile-build
index aea03c5..e2a73b7 100644
--- a/jenkinsfile/Jenkinsfile-build
+++ b/jenkinsfile/Jenkinsfile-build
@@ -1,4 +1,5 @@
def nuxeo_package_helper = evaluate readTrusted('src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy')
+def openshift_builder = evaluate readTrusted('src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy')
def project = ""
def project_git_repo = ""
def project_git_ref = ""
@@ -86,24 +87,14 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- if (fileExists("source")) {
- sh "rm -rf source"
- }
- sh "mkdir -p source"
- nuxeo_package_helper.unstash_nuxeo_package "*"
+ nuxeo_package_helper.set_build_directory "source"
+ nuxeo_package_helper.unstash_nuxeo_package("*", "source")

// Build docker image
- openshift.selector("bc", nuxeo_image_build).startBuild("--from-dir='source'", "--wait")
- def build_last_version = openshift.selector("bc", nuxeo_image_build).object().status.lastVersion
- def last_build = openshift.selector("builds", "${nuxeo_image_build}-${build_last_version}")
- timeout(10) {
- waitUntil {
- last_build.object().status.phase == "Complete"
- }
- }
+ openshift_builder.build_docker_image(nuxeo_image_build, "source")

- // Promote to dev
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:dev")
+ // Promote docker image to dev
+ openshift_builder.tag_docker_image(nuxeo_image_name, "dev")
}
}
}
@@ -115,12 +106,7 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- openshiftDeploy(deploymentConfig: "${app_name}-dev-interactive")
- timeout(5) {
- openshift.selector("dc", "${app_name}-dev-interactive").related('pods').untilEach(1) {
- return (it.object().status.phase == "Running")
- }
- }
+ openshift_builder.deploy_docker_image "${app_name}-dev-interactive"
}
}
}
@@ -182,7 +168,7 @@ pipeline {
openshift.withProject() {
timeout(60) {
input message: "Do you want to deploy to UAT environment too?", id: "approval"
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:uat")
+ openshift_builder.tag_docker_image(nuxeo_image_name, "uat")
}
}
}
@@ -195,12 +181,7 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- openshiftDeploy(deploymentConfig: "${app_name}-uat-interactive")
- timeout(5) {
- openshift.selector("dc", "${app_name}-uat-interactive").related('pods').untilEach(1) {
- return (it.object().status.phase == "Running")
- }
- }
+ openshift_builder.deploy_docker_image "${app_name}-uat-interactive"
}
}
}
diff --git a/jenkinsfile/Jenkinsfile-release b/jenkinsfile/Jenkinsfile-release
index fae1257..83a97c7 100644
--- a/jenkinsfile/Jenkinsfile-release
+++ b/jenkinsfile/Jenkinsfile-release
@@ -1,4 +1,5 @@
def nuxeo_package_helper = evaluate readTrusted('src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy')
+def openshift_builder = evaluate readTrusted('src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy')
def project = ""
def nuxeo_image_build = ""
def nuxeo_image_name = ""
@@ -139,24 +140,14 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- if (fileExists("source")) {
- sh "rm -rf source"
- }
- sh "mkdir -p source"
- nuxeo_package_helper.unstash_nuxeo_package release_tag
+ nuxeo_package_helper.set_build_directory "source"
+ nuxeo_package_helper.unstash_nuxeo_package(release_tag, "source")

// Build docker image
- openshift.selector("bc", nuxeo_image_build).startBuild("--from-dir='source'", "--wait")
- def build_last_version = openshift.selector("bc", nuxeo_image_build).object().status.lastVersion
- def last_build = openshift.selector("builds", "${nuxeo_image_build}-${build_last_version}")
- timeout(10) {
- waitUntil {
- last_build.object().status.phase == "Complete"
- }
- }
+ openshift_builder.build_docker_image(nuxeo_image_build, "source")

- // Promote to release version
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:v${release_tag}")
+ // Promote docker image to the release tag
+ openshift_builder.tag_docker_image(nuxeo_image_name, "v${release_tag}")
}
}
}
diff --git a/jenkinsfile/Jenkinsfile-single b/jenkinsfile/Jenkinsfile-single
index 4f29261..248597e 100644
--- a/jenkinsfile/Jenkinsfile-single
+++ b/jenkinsfile/Jenkinsfile-single
@@ -1,4 +1,5 @@
def nuxeo_package_helper = evaluate readTrusted('src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy')
+def openshift_builder = evaluate readTrusted('src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy')
def project = ""
def pipeline_name = ""
def project_git_repo = ""
@@ -83,41 +84,26 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- if (fileExists("source")) {
- sh "rm -rf source"
- }
- sh "mkdir -p source"
- nuxeo_package_helper.unstash_nuxeo_package "*"
+ nuxeo_package_helper.set_build_directory "source"
+ nuxeo_package_helper.unstash_nuxeo_package("*", "source")

// Build docker image
- openshift.selector("bc", nuxeo_image_build).startBuild("--from-dir='source'", "--wait")
- def build_last_version = openshift.selector("bc", nuxeo_image_build).object().status.lastVersion
- def last_build = openshift.selector("builds", "${nuxeo_image_build}-${build_last_version}")
- timeout(10) {
- waitUntil {
- last_build.object().status.phase == "Complete"
- }
- }
+ openshift_builder.build_docker_image(nuxeo_image_build, "source")

- // Promote to dev
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:${pipeline_name}")
+ // Promote docker image to the pipeline name
+ openshift_builder.tag_docker_image(nuxeo_image_name, pipeline_name)
}
}
}
}
}

- stage('Deploy env') {
+ stage('Deploy Env') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
- openshiftDeploy(deploymentConfig: "${app_name}-${pipeline_name}-interactive")
- timeout(5) {
- openshift.selector("dc", "${app_name}-${pipeline_name}-interactive").related('pods').untilEach(1) {
- return (it.object().status.phase == "Running")
- }
- }
+ openshift_builder.deploy_docker_image "${app_name}-${pipeline_name}-interactive"
}
}
}
diff --git a/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy b/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy
index 6dd1b3d..86200c2 100644
--- a/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy
+++ b/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy
@@ -5,10 +5,10 @@ def stash_nuxeo_package(version) {
stashContent("package", nuxeoPackageFile)
}

-def unstash_nuxeo_package(version) {
+def unstash_nuxeo_package(version, dirName) {
unstashContent("package")
def nuxeoPackageFile = find(version)
- moveAndRenameFile(nuxeoPackageFile, "source", "marketplace.zip")
+ moveAndRenameFile(nuxeoPackageFile, dirName, "marketplace.zip")
}

def find(version) {
@@ -33,6 +33,13 @@ def find(version) {
return null
}

+def set_build_directory(dirName) {
+ if (fileExists(dirName)) {
+ sh "rm -rf ${dirName}"
+ }
+ sh "mkdir -p ${dirName}"
+}
+
protected stashContent(stashName, includes) {
stash name:stashName, includes:"${includes}"
}
diff --git a/src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy b/src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy
new file mode 100644
index 0000000..9f45598
--- /dev/null
+++ b/src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy
@@ -0,0 +1,32 @@
+package org.nuxeo.openshift.library
+
+def build_docker_image(nuxeoImageBuild, fromDir=null) {
+ def buildConfig = openshift.selector("bc", nuxeoImageBuild)
+ if (fromDir) {
+ buildConfig.startBuild("--from-dir='${fromDir}'", "--wait")
+ } else {
+ buildConfig.startBuild("--wait")
+ }
+ def buildLastVersion = openshift.selector("bc", nuxeoImageBuild).object().status.lastVersion
+ def lastBuild = openshift.selector("builds", "${nuxeoImageBuild}-${buildLastVersion}")
+ timeout(10) {
+ waitUntil {
+ lastBuild.object().status.phase == "Complete"
+ }
+ }
+}
+
+def tag_docker_image(nuxeoImageName, tag) {
+ openshift.tag("${nuxeoImageName}:latest", "${nuxeoImageName}:${tag}")
+}
+
+def deploy_docker_image(deploymentConfigName) {
+ openshiftDeploy(deploymentConfig: deploymentConfigName)
+ timeout(5) {
+ openshift.selector("dc", deploymentConfigName).related('pods').untilEach(1) {
+ return (it.object().status.phase == "Running")
+ }
+ }
+}
+
+return this
--
You received this message because you are subscribed to the Google Groups "ecm-checkins" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ecm-checkins+***@lists.nuxeo.com.
Visit this group at https://groups.google.com/a/lists.nuxeo.com/group/ecm-checkins/.
Estelle Giuly
2018-12-11 09:25:17 UTC
Permalink
Message:
NXCT-147: Add OpenshiftBuilder lib to build. tag, deploy image

Repository: nuxeo-openshift
Branch: NXCT-147-openshift-builder-library
Author: Estelle Giuly <***@nuxeo.com>
Date: 2018-12-11T09:23:53 UTC
URL: https://github.com/nuxeo/nuxeo-openshift/commit/513153e6f7707a8c7fd3d52c9dc4e4951fc7e229
JIRA: https://jira.nuxeo.com/browse/NXCT-147

Files:
A src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy
M jenkinsfile/Jenkinsfile-build
M jenkinsfile/Jenkinsfile-release
M jenkinsfile/Jenkinsfile-single
M src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy

diff --git a/jenkinsfile/Jenkinsfile-build b/jenkinsfile/Jenkinsfile-build
index aea03c5..e2a73b7 100644
--- a/jenkinsfile/Jenkinsfile-build
+++ b/jenkinsfile/Jenkinsfile-build
@@ -1,4 +1,5 @@
def nuxeo_package_helper = evaluate readTrusted('src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy')
+def openshift_builder = evaluate readTrusted('src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy')
def project = ""
def project_git_repo = ""
def project_git_ref = ""
@@ -86,24 +87,14 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- if (fileExists("source")) {
- sh "rm -rf source"
- }
- sh "mkdir -p source"
- nuxeo_package_helper.unstash_nuxeo_package "*"
+ nuxeo_package_helper.set_build_directory "source"
+ nuxeo_package_helper.unstash_nuxeo_package("*", "source")

// Build docker image
- openshift.selector("bc", nuxeo_image_build).startBuild("--from-dir='source'", "--wait")
- def build_last_version = openshift.selector("bc", nuxeo_image_build).object().status.lastVersion
- def last_build = openshift.selector("builds", "${nuxeo_image_build}-${build_last_version}")
- timeout(10) {
- waitUntil {
- last_build.object().status.phase == "Complete"
- }
- }
+ openshift_builder.build_docker_image(nuxeo_image_build, "source")

- // Promote to dev
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:dev")
+ // Promote docker image to dev
+ openshift_builder.tag_docker_image(nuxeo_image_name, "dev")
}
}
}
@@ -115,12 +106,7 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- openshiftDeploy(deploymentConfig: "${app_name}-dev-interactive")
- timeout(5) {
- openshift.selector("dc", "${app_name}-dev-interactive").related('pods').untilEach(1) {
- return (it.object().status.phase == "Running")
- }
- }
+ openshift_builder.deploy_docker_image "${app_name}-dev-interactive"
}
}
}
@@ -182,7 +168,7 @@ pipeline {
openshift.withProject() {
timeout(60) {
input message: "Do you want to deploy to UAT environment too?", id: "approval"
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:uat")
+ openshift_builder.tag_docker_image(nuxeo_image_name, "uat")
}
}
}
@@ -195,12 +181,7 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- openshiftDeploy(deploymentConfig: "${app_name}-uat-interactive")
- timeout(5) {
- openshift.selector("dc", "${app_name}-uat-interactive").related('pods').untilEach(1) {
- return (it.object().status.phase == "Running")
- }
- }
+ openshift_builder.deploy_docker_image "${app_name}-uat-interactive"
}
}
}
diff --git a/jenkinsfile/Jenkinsfile-release b/jenkinsfile/Jenkinsfile-release
index fae1257..83a97c7 100644
--- a/jenkinsfile/Jenkinsfile-release
+++ b/jenkinsfile/Jenkinsfile-release
@@ -1,4 +1,5 @@
def nuxeo_package_helper = evaluate readTrusted('src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy')
+def openshift_builder = evaluate readTrusted('src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy')
def project = ""
def nuxeo_image_build = ""
def nuxeo_image_name = ""
@@ -139,24 +140,14 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- if (fileExists("source")) {
- sh "rm -rf source"
- }
- sh "mkdir -p source"
- nuxeo_package_helper.unstash_nuxeo_package release_tag
+ nuxeo_package_helper.set_build_directory "source"
+ nuxeo_package_helper.unstash_nuxeo_package(release_tag, "source")

// Build docker image
- openshift.selector("bc", nuxeo_image_build).startBuild("--from-dir='source'", "--wait")
- def build_last_version = openshift.selector("bc", nuxeo_image_build).object().status.lastVersion
- def last_build = openshift.selector("builds", "${nuxeo_image_build}-${build_last_version}")
- timeout(10) {
- waitUntil {
- last_build.object().status.phase == "Complete"
- }
- }
+ openshift_builder.build_docker_image(nuxeo_image_build, "source")

- // Promote to release version
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:v${release_tag}")
+ // Promote docker image to the release tag
+ openshift_builder.tag_docker_image(nuxeo_image_name, "v${release_tag}")
}
}
}
diff --git a/jenkinsfile/Jenkinsfile-single b/jenkinsfile/Jenkinsfile-single
index 4f29261..248597e 100644
--- a/jenkinsfile/Jenkinsfile-single
+++ b/jenkinsfile/Jenkinsfile-single
@@ -1,4 +1,5 @@
def nuxeo_package_helper = evaluate readTrusted('src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy')
+def openshift_builder = evaluate readTrusted('src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy')
def project = ""
def pipeline_name = ""
def project_git_repo = ""
@@ -83,41 +84,26 @@ pipeline {
script {
openshift.withCluster() {
openshift.withProject() {
- if (fileExists("source")) {
- sh "rm -rf source"
- }
- sh "mkdir -p source"
- nuxeo_package_helper.unstash_nuxeo_package "*"
+ nuxeo_package_helper.set_build_directory "source"
+ nuxeo_package_helper.unstash_nuxeo_package("*", "source")

// Build docker image
- openshift.selector("bc", nuxeo_image_build).startBuild("--from-dir='source'", "--wait")
- def build_last_version = openshift.selector("bc", nuxeo_image_build).object().status.lastVersion
- def last_build = openshift.selector("builds", "${nuxeo_image_build}-${build_last_version}")
- timeout(10) {
- waitUntil {
- last_build.object().status.phase == "Complete"
- }
- }
+ openshift_builder.build_docker_image(nuxeo_image_build, "source")

- // Promote to dev
- openshift.tag("${nuxeo_image_name}:latest", "${nuxeo_image_name}:${pipeline_name}")
+ // Promote docker image to the pipeline name
+ openshift_builder.tag_docker_image(nuxeo_image_name, pipeline_name)
}
}
}
}
}

- stage('Deploy env') {
+ stage('Deploy Env') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
- openshiftDeploy(deploymentConfig: "${app_name}-${pipeline_name}-interactive")
- timeout(5) {
- openshift.selector("dc", "${app_name}-${pipeline_name}-interactive").related('pods').untilEach(1) {
- return (it.object().status.phase == "Running")
- }
- }
+ openshift_builder.deploy_docker_image "${app_name}-${pipeline_name}-interactive"
}
}
}
diff --git a/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy b/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy
index 6dd1b3d..86200c2 100644
--- a/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy
+++ b/src/org/nuxeo/openshift/library/NuxeoPackageHelper.groovy
@@ -5,10 +5,10 @@ def stash_nuxeo_package(version) {
stashContent("package", nuxeoPackageFile)
}

-def unstash_nuxeo_package(version) {
+def unstash_nuxeo_package(version, dirName) {
unstashContent("package")
def nuxeoPackageFile = find(version)
- moveAndRenameFile(nuxeoPackageFile, "source", "marketplace.zip")
+ moveAndRenameFile(nuxeoPackageFile, dirName, "marketplace.zip")
}

def find(version) {
@@ -33,6 +33,13 @@ def find(version) {
return null
}

+def set_build_directory(dirName) {
+ if (fileExists(dirName)) {
+ sh "rm -rf ${dirName}"
+ }
+ sh "mkdir -p ${dirName}"
+}
+
protected stashContent(stashName, includes) {
stash name:stashName, includes:"${includes}"
}
diff --git a/src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy b/src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy
new file mode 100644
index 0000000..220e1c8
--- /dev/null
+++ b/src/org/nuxeo/openshift/library/OpenshiftBuilder.groovy
@@ -0,0 +1,32 @@
+package org.nuxeo.openshift.library
+
+def build_docker_image(nuxeoImageBuild, fromDir=null) {
+ def buildConfig = openshift.selector("bc", nuxeoImageBuild)
+ if (fromDir) {
+ buildConfig.startBuild("--from-dir='${fromDir}'", "--wait")
+ } else {
+ buildConfig.startBuild("--wait")
+ }
+ def buildLastVersion = openshift.selector("bc", nuxeoImageBuild).object().status.lastVersion
+ def lastBuild = openshift.selector("builds", "${nuxeoImageBuild}-${buildLastVersion}")
+ timeout(10) {
+ waitUntil {
+ lastBuild.object().status.phase == "Complete"
+ }
+ }
+}
+
+def tag_docker_image(nuxeoImageName, tag) {
+ openshift.tag("${nuxeoImageName}:latest", "${nuxeoImageName}:${tag}")
+}
+
+def deploy_docker_image(deploymentConfigName) {
+ openshiftDeploy(deploymentConfig: deploymentConfigName)
+ timeout(5) {
+ openshift.selector("dc", deploymentConfigName).related('pods').untilEach(1) {
+ return (it.object().status.phase == "Running")
+ }
+ }
+}
+
+return this
--
You received this message because you are subscribed to the Google Groups "ecm-checkins" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ecm-checkins+***@lists.nuxeo.com.
Visit this group at https://groups.google.com/a/lists.nuxeo.com/group/ecm-checkins/.
Loading...