diff --git a/pipelines/Docs/Eisen/doxygen.groovy b/pipelines/Docs/Eisen/doxygen.groovy index 91a3f2e..caa1746 100644 --- a/pipelines/Docs/Eisen/doxygen.groovy +++ b/pipelines/Docs/Eisen/doxygen.groovy @@ -1,6 +1,8 @@ +/* groovylint-disable NestedBlockDepth */ @Library('shared-lib') _ import tech.avroid.scm.Git +import tech.avroid.api.Nexus properties([ buildDiscarder(logRotator(numToKeepStr: '100')), @@ -28,13 +30,13 @@ String nexusRepoName = 'eisen-os_doc-feature' Git git = new Git(this, env.JENKINS_GIT_CREDENTIALS_SSH) podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), - yaml: ''' + yaml: """ apiVersion: v1 kind: Pod spec: containers: - name: doxygen - image: harbor.avroid.tech/devops/doxygen:1.9.8 + image: ${env.JENKINS_DOCKER_REGISTRY}/devops/doxygen:1.9.8 securityContext: runAsUser: 1000 runAsGroup: 1000 @@ -50,7 +52,7 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), imagePullPolicy: Always imagePullSecrets: - name: harbor-registry-secret -''' +""" ) { node(POD_LABEL) { @@ -79,6 +81,8 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), return } + Nexus nexus = new Nexus(this, env.JENKINS_NEXUS_URL, env.JENKINS_NEXUS_CREDENTIALS) + stage('Checkout source') { git.clone(urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${gitRepoName}.git", branch: branchName, @@ -103,29 +107,31 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), } String mainDocDir = 'documentation' - String projectDir = 'OS' dateFormat = sh(returnStdout: true, script: "date '+%d-%m-%Y_%H-%M'").trim() String publishDir = "${dateFormat}_${branchName}" - String mainHTMLFile = "main.html" + String mainHTMLFile = 'main.html' + String latestHTMLFile = 'latest.html' println 'Publish dir is: ' + publishDir + String fullUrl = "${env.JENKINS_NEXUS_URL}/repository/${nexusRepoName}" + + "/${mainDocDir}/${publishDir}/html/index.html" stage('Generate documentation') { dir(projectName) { container(name: 'doxygen') { script { sh """ doxygen - echo '${publishDir}' > documentation.html + echo '${publishDir}' > documentation.html """ } } } } - stage('Generate main html file') { + stage('Generate common html files') { dir(projectName) { res = httpRequest( - url: "${env.JENKINS_NEXUS_URL}/service/rest/repository/browse/${nexusRepoName}/${mainDocDir}/${projectDir}", + url: "${env.JENKINS_NEXUS_URL}/service/rest/repository/browse/${nexusRepoName}/${mainDocDir}", httpMode: 'GET', quiet: true, validResponseCodes: "200,201,404", @@ -137,7 +143,8 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), def lines = content.readLines() - java.util.regex.Pattern regexpPattern = (java.util.regex.Pattern)~/([0-9]+(-[0-9]+)+)_([0-9]+(-[0-9]+)+)_[A-Za-z0-9]+/ + java.util.regex.Pattern regexpPattern = + (java.util.regex.Pattern)~/([0-9]+(-[0-9]+)+)_([0-9]+(-[0-9]+)+)_[A-Za-z0-9]+/ List docs = [] @@ -150,15 +157,18 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), } println docs - + String docUrl = "" docs.each { doc -> + docUrl = "${env.JENKINS_NEXUS_URL}/repository/${nexusRepoName}" + + "/${mainDocDir}/${doc}/html/index.html" sh """ - echo '${doc}
' >> ${mainHTMLFile} + echo '${doc}
' >> ${mainHTMLFile} """ } } sh """ - echo '${publishDir}' >> ${mainHTMLFile} + echo '${publishDir}' >> ${mainHTMLFile} + echo '' > ${latestHTMLFile} """ } } @@ -168,23 +178,30 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: '/data'), usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { - dir("${projectName}/") { - res = httpRequest( - url: "${env.JENKINS_NEXUS_URL}/repository/${nexusRepoName}/${mainDocDir}/${projectDir}/${mainHTMLFile}", - authentication: env.JENKINS_NEXUS_CREDENTIALS, - httpMode: "PUT", - uploadFile: mainHTMLFile, - validResponseCodes: "201", - wrapAsMultipart: false - ) - println("Status: "+res.status) + List customHTMLFiles = [mainHTMLFile, latestHTMLFile] + dir("${projectName}/") { + + customHTMLFiles.each { htmlFile -> + String artifactUrl = "${env.JENKINS_NEXUS_URL}/repository/" + + "${nexusRepoName}/${mainDocDir}/${htmlFile}" + nexus.upload( + script: this, + artifactUrl: "${artifactUrl}", + host: env.JENKINS_NEXUS_URL, // + + credentials: env.JENKINS_NEXUS_CREDENTIALS, // + + artifactPath: htmlFile, + repository: nexusRepoName + ) + + } + } dir("${projectName}/Eisen_Docs/html/") { sh """ find . -type f -exec curl -s --user ${USERNAME}:${PASSWORD} --ftp-create-dirs -T {} \ - ${env.JENKINS_NEXUS_URL}/repository/${nexusRepoName}/${mainDocDir}/${projectDir}/${publishDir}/html/{} \\; + ${env.JENKINS_NEXUS_URL}/repository/${nexusRepoName}/${mainDocDir}/${publishDir}/html/{} \\; """ } }