This is an automated email from the ASF dual-hosted git repository. rlenferink pushed a commit to branch feature/gh-source-test in repository https://gitbox.apache.org/repos/asf/celix-site.git
commit cc5221c1f87e46230a5d8c82411938e94ce1073b Author: Roy Lenferink <[email protected]> AuthorDate: Sun Feb 26 15:41:32 2023 +0100 Update Jenkinsfile for usage with GitHub branch source in Jenkins --- Jenkinsfile | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bd87e57..9811c06 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { environment { HUGO_VERSION = '0.63.2' DEPLOY_BRANCH = 'asf-site' + REPO_URL = 'https://github.com/apache/celix-site.git' } stages { @@ -49,6 +50,8 @@ pipeline { env.OUT_DIR = "${env.TMP_DIR}/content" sh "mkdir -p ${env.OUT_DIR}" + // Setup directory for Gitbox checkout + env.GITBOX_REPO = sh(script:'mktemp -d', returnStdout: true).trim() } } } @@ -69,29 +72,28 @@ pipeline { } steps { script { - // Checkout branch with generated content - sh """ - git checkout ${DEPLOY_BRANCH} - git pull origin ${DEPLOY_BRANCH} - """ - - // Remove the content of the target branch and replace it with the content of the temp folder - sh """ - rm -rf ${WORKSPACE}/content - git rm -r --cached content/* - mkdir -p ${WORKSPACE}/content - cp -rT ${env.TMP_DIR}/* ${WORKSPACE}/content - """ - - // Commit the changes to the target branch - env.COMMIT_MESSAGE = "Updated site from ${BRANCH_NAME} (${env.LAST_SHA})" - sh """ - git add -A - git commit -m "${env.COMMIT_MESSAGE}" | true - """ - - // Push the generated content for deployment - sh "git push -u origin ${DEPLOY_BRANCH}" + // Clone the Gitbox repo because that allows deployment to the asf-site branch + sh "git clone -b asf-site https://gitbox.apache.org/repos/asf/celix-site.git ${env.GITBOX_REPO}" + + dir("${env.GITBOX_REPO}") { + // Remove the content of the target branch and replace it with the content of the temp folder + sh """ + rm -rf ${env.GITBOX_REPO}/content + git rm -r --cached content/* + mkdir -p ${env.GITBOX_REPO}/content + cp -rT ${env.TMP_DIR}/* ${env.GITBOX_REPO}/content + """ + + // Commit the changes to the target branch + env.COMMIT_MESSAGE = "Updated site from ${BRANCH_NAME} (${env.LAST_SHA})" + sh """ + git add -A + git commit -m "${env.COMMIT_MESSAGE}" | true + """ + + // Push the generated content for deployment + sh "git push -u origin ${DEPLOY_BRANCH}" + } } } } @@ -103,6 +105,7 @@ pipeline { sh """ rm -rf ${env.HUGO_DIR} rm -rf ${env.TMP_DIR} + rm -rf ${env.GITBOX_REPO} """ } deleteDir() /* clean up our workspace */
