From 6533c52ce5d8f35f0a04e84951b07c6187215088 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Fri, 15 Nov 2024 15:31:52 +0100 Subject: [PATCH] wip: push using gh --- Jenkinsfile | 81 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4d21ab20..97b931a7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,20 +22,83 @@ pipeline { } stages { - stage('build') { + // stage('build') { + // steps { + // script { + // setupGPGEnvironment() + // withCredentials([string(credentialsId: 'gpg.password', variable: 'GPG_PWD')]) { + // def phase = isReleaseOrMasterBranch() ? 'deploy site-deploy' : 'verify' + // maven cmd: "clean verify " + + // "-Dgpg.skip=false " + + // "-Dgpg.project-build.password='${env.GPG_PWD}' " + + // "-Dgithub.site.skip=${params.skipGitHubSite} " + + // "-Divy.engine.list.url=${params.engineListUrl} " + + // "-Dmaven.test.failure.ignore=true" + // } + // collectBuildArtifacts() + // } + // } + // } + stage('deploy-site') { + // when { + // expression { isReleaseOrMasterBranch() } + // } steps { script { setupGPGEnvironment() withCredentials([string(credentialsId: 'gpg.password', variable: 'GPG_PWD')]) { - def phase = isReleaseOrMasterBranch() ? 'deploy site-deploy' : 'verify' - maven cmd: "clean ${phase} " + - "-Dgpg.skip=false " + - "-Dgpg.project-build.password='${env.GPG_PWD}' " + - "-Dgithub.site.skip=${params.skipGitHubSite} " + - "-Divy.engine.list.url=${params.engineListUrl} " + - "-Dmaven.test.failure.ignore=true" + maven cmd: "clean site " + + "-Divy.engine.list.url=${params.engineListUrl} " } - collectBuildArtifacts() + + // sh ''' + // tmpOut=$(mktemp -d -t "plugin-site-XXXXX") + // cp -r . $tmpOut + // cd $tmpOut + // git checkout -b gh_pages + + + // cd target/site && zip -r $tmpOut/site.zip . + // git checkout -b origin/gh_pages + // unzip $tmpOut/site.zip + // git add . + // git commit + // ''' + + + + + // sh "git checkout -b ${targetBranch}" + + withEnv(['GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no']) { + sshagent(credentials: ['github-axonivy']) { + def branch = "pages_$BRANCH_NAME-$BUILD_NUMBER" + def message = "Update site (${env.BRANCH_NAME})" + withCredentials([file(credentialsId: 'github-ivyteam-token-repo-manager', variable: 'tokenFile')]) { + sh """ + git config --global user.name 'ivy-team' + git config --global user.email 'info@ivyteam.ch' + gh auth login --with-token < ${tokenFile} + + echo 'preparing ${branch}' + gh repo clone git@github.com:axonivy/project-build-plugin.git target/site-deployer + cd target/site-deployer + git checkout -b ${branch} origin/gh-pages + git --no-pager status + cd ../site + cp -r -v . ../site-deployer + #cp -r -v ../site/ . + cd ../site-deployer + ls -la + git add . + git commit -m '${message}' + #gh pr create --base 'gh-pages' --fill + git push origin ${branch} + """ + } + } + } + } } }