You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bn...@apache.org on 2021/10/15 15:11:25 UTC

[trafficserver-ci] branch main updated: docs branch build: split build and install hosts using stash/unstash

This is an automated email from the ASF dual-hosted git repository.

bnolsen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/trafficserver-ci.git


The following commit(s) were added to refs/heads/main by this push:
     new 8d725ae  docs branch build: split build and install hosts using stash/unstash
     new 7ff64ee  Merge pull request #60 from traeak/doc_stash
8d725ae is described below

commit 8d725aedc12772f9190494ab1a8f897bd6f46539
Author: Brian Olsen <bn...@gmail.com>
AuthorDate: Thu Oct 14 11:17:37 2021 -0700

    docs branch build: split build and install hosts using stash/unstash
---
 jenkins/bin/docs.sh          |  12 ++---
 jenkins/branch/docs.pipeline | 124 +++++++++++++++++++++++++++----------------
 2 files changed, 84 insertions(+), 52 deletions(-)

diff --git a/jenkins/bin/docs.sh b/jenkins/bin/docs.sh
index 03c3a7f..37e2265 100755
--- a/jenkins/bin/docs.sh
+++ b/jenkins/bin/docs.sh
@@ -43,7 +43,7 @@ jaoutdir="${outputdir}/ja/${vername}"
 
 sudo chmod -R 777 . || exit 1
 
-pushd doc
+cd doc
 pipenv install || exit 1
 
 tmpfile=/tmp/build_the_docs.$$
@@ -83,10 +83,10 @@ cd "${outputdir}"
 
 sudo chmod -R u=rwX,g=rX,o=rX . || exit 1
 
-if [ "${PUBLISH_DOCS}" == "true" ]; then
-	sudo cp -avx ja /home/docs
-	sudo cp -avx en /home/docs
-	/home/docs/docs_purge.sh ${vername}
-fi
+#if [ "${PUBLISH_DOCS}" == "true" ]; then
+#	sudo cp -avx ja /home/docs
+#	sudo cp -avx en /home/docs
+#	/home/docs/docs_purge.sh ${vername}
+#fi
 
 exit 0
diff --git a/jenkins/branch/docs.pipeline b/jenkins/branch/docs.pipeline
index 47eada2..8ce0c13 100644
--- a/jenkins/branch/docs.pipeline
+++ b/jenkins/branch/docs.pipeline
@@ -1,15 +1,16 @@
 pipeline {
-	agent {
-		docker {
-			image 'controller.trafficserver.org/ats/centos:8'
-			registryUrl 'https://controller.trafficserver.org/'
-			args '--network=host -v "/home/docs:/home/docs:rw"'
-			label 'docs'
-		}
-	}
+	agent none
 
 	stages {
-		stage('Initialization') {
+		stage('Build') {
+			agent {
+				docker {
+					image 'controller.trafficserver.org/ats/centos:8'
+					registryUrl 'https://controller.trafficserver.org/'
+					args '--network=host'
+					label 'branch'
+				}
+			}
 			steps {
 				script {
 					if (! env.GITHUB_BRANCH) {
@@ -25,29 +26,21 @@ pipeline {
 					}
 					sh 'printenv'
 				}
-			}
-		}
-		stage('Clone') {
-			steps {
+
 				dir('ci') {
 					git url: 'https://github.com/apache/trafficserver-ci',
 						branch: 'main'
 				}
+
 				dir('src') {
 					script {
 						String branch = env.SHA1
 						if (! branch) {
 							branch = '*/' + env.GITHUB_BRANCH
 						}
-						try {
-							checkout([$class: 'GitSCM',
-								branches: [[name: branch]],
-								userRemoteConfigs: [[url: env.GITHUB_URL]],
-								extensions: [[$class: 'CloneOption', timeout: 10]]
-							])
-						} catch (error) {
-							echo "Clone failed, retry"
-							retry(2) {
+
+						timeout(time: 1, unit: 'MINUTES') {
+							retry(3) {
 								checkout([$class: 'GitSCM',
 									branches: [[name: branch]],
 									userRemoteConfigs: [[url: env.GITHUB_URL]],
@@ -58,10 +51,7 @@ pipeline {
 					}
 				}
 				echo 'Finished Cloning'
-			}
-		}
-		stage('Build') {
-			steps {
+
 				echo 'Starting build'
 				dir('src') {
 					// For Jenkins debugging. We comit to the top of README in our debug PRs.
@@ -71,29 +61,71 @@ pipeline {
 					bash -x ../ci/jenkins/bin/docs.sh
 					'''
 				}
+
+				echo "Stashing"
+				dir('src/output') {
+					script {
+						if (env.PUBLISH_DOCS == "true") {
+							echo 'stashing docs'
+			  			stash includes: 'en/**,ja/**', name: "docs"
+						}
+					}
+				}
 			}
-		}
-	}
-	post {
-		success {
-//			archiveArtifacts artifacts: "src/output/${GITHUB_BRANCH}/**/*", fingerprint: false, allowEmptyArchive: true
-			archiveArtifacts artifacts: "src/output/**/*", fingerprint: false, allowEmptyArchive: true
-			publishHTML (target : [
-				allowMissing: true,
-				alwaysLinkToLastBuild: false,
-				keepAll: true,
-				reportDir: "src/output/en/${GITHUB_BRANCH}/",
-				reportFiles: 'index.html',
-				reportName: "Sphinx Docs"])
+			post {
+				success {
+					archiveArtifacts artifacts: "src/output/**/*", fingerprint: false, allowEmptyArchive: true
+					publishHTML (target : [
+						allowMissing: true,
+						alwaysLinkToLastBuild: false,
+						keepAll: true,
+						reportDir: "src/output/en/${GITHUB_BRANCH}/",
+						reportFiles: 'index.html',
+						reportName: "Sphinx Docs"])
 
-			sh'''
-				echo
-				echo "See the job's Build artifacts and click on index.html for the rendered docs."
-				echo
-				'''
+					sh'''
+						echo
+						echo "See the job's Build artifacts and click on index.html for the rendered docs."
+						echo
+						'''
+				}
+				always {
+					cleanWs()
+				}
+			}
 		}
-		cleanup {
-			cleanWs()
+
+		stage('Install') {
+			when {
+				environment name: 'PUBLISH_DOCS', value: 'true'
+			}
+			agent {
+				docker {
+					image 'controller.trafficserver.org/ats/centos:8'
+					registryUrl 'https://controller.trafficserver.org/'
+					args '--network=host -v "/home/docs/:/home/docs:rw"'
+					label 'docs'
+				}
+			}
+			steps {
+				echo "Installing"
+				script {
+					if (env.PUBLISH_DOCS == "true" && env.GITHUB_BRANCH != "") {
+						echo "unstashing"
+						unstash 'docs'
+						sh '''
+						sudo cp -avx ja /home/docs
+						sudo cp -avx en /home/docs
+						/home/docs/docs_purge.sh ${GITHUB_BRANCH}
+						'''
+					}
+				}
+			}
+			post {
+				always {
+					cleanWs()
+				}
+			}
 		}
 	}
 }