|
| 1 | +#!/usr/bin/env groovy |
| 2 | + |
| 3 | +pipeline { |
| 4 | + agent { label 'gelman-group-linux' } |
| 5 | + options { |
| 6 | + skipDefaultCheckout() |
| 7 | + preserveStashes(buildCount: 5) |
| 8 | + } |
| 9 | + parameters { |
| 10 | + string(defaultValue: '', name: 'major_version', description: "Major version of the docs to be built") |
| 11 | + string(defaultValue: '', name: 'minor_version', description: "Minor version of the docs to be built") |
| 12 | + } |
| 13 | + environment { |
| 14 | + GITHUB_TOKEN = credentials('6e7c1e8f-ca2c-4b11-a70e-d934d3f6b681') |
| 15 | + } |
| 16 | + stages { |
| 17 | + stage('Clean checkout for docs') { |
| 18 | + steps { |
| 19 | + deleteDir() |
| 20 | + checkout([$class: 'GitSCM', |
| 21 | + branches: [[name: '*/master']], |
| 22 | + doGenerateSubmoduleConfigurations: false, |
| 23 | + extensions: [], |
| 24 | + submoduleCfg: [], |
| 25 | + userRemoteConfigs: [[url: "https://github.com/stan-dev/docs.git", credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b']]] |
| 26 | + ) |
| 27 | + } |
| 28 | + } |
| 29 | + stage("Create branch for docs") { |
| 30 | + steps { |
| 31 | + withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b', |
| 32 | + usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) { |
| 33 | + sh """#!/bin/bash |
| 34 | + git checkout -b docs-$major_version-$minor_version |
| 35 | + """ |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + stage("Build docs") { |
| 40 | + steps{ |
| 41 | + sh "python build.py $major_version $minor_version" |
| 42 | + } |
| 43 | + } |
| 44 | + stage("Add redirects for docs") { |
| 45 | + steps{ |
| 46 | + sh "python add_redirects.py $major_version $minor_version functions-reference" |
| 47 | + sh "python add_redirects.py $major_version $minor_version reference-manual" |
| 48 | + sh "python add_redirects.py $major_version $minor_version stan-users-guide" |
| 49 | + } |
| 50 | + } |
| 51 | + stage("Push PR for docs") { |
| 52 | + steps { |
| 53 | + withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b', |
| 54 | + usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) { |
| 55 | + sh """#!/bin/bash |
| 56 | + git config --global user.email "[email protected]" |
| 57 | + git config --global user.name "Stan Jenkins" |
| 58 | + git config --global auth.token ${GITHUB_TOKEN} |
| 59 | +
|
| 60 | + git add . |
| 61 | + git commit -m "Documentation generated from Jenkins for docs-$major_version-$minor_version" |
| 62 | + git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/stan-dev/docs.git docs-$major_version-$minor_version |
| 63 | +
|
| 64 | + curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST -d '{"title": "Docs generated by Jenkins for v$major_version-$minor_version", "head":"docs-$major_version-$minor_version", "base":"master", "body":"Docs generated through the [Jenkins Job](https://jenkins.mc-stan.org/job/BuildDocs/)"}' "https://api.github.com/repos/stan-dev/docs/pulls" |
| 65 | + """ |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + stage('Clean checkout for cmdstan') { |
| 70 | + steps { |
| 71 | + deleteDir() |
| 72 | + checkout([$class: 'GitSCM', |
| 73 | + branches: [[name: '*/master']], |
| 74 | + doGenerateSubmoduleConfigurations: false, |
| 75 | + extensions: [], |
| 76 | + submoduleCfg: [], |
| 77 | + userRemoteConfigs: [[url: "https://github.com/stan-dev/cmdstan.git", credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b']]] |
| 78 | + ) |
| 79 | + } |
| 80 | + } |
| 81 | + stage("Build cmdstan manual") { |
| 82 | + steps{ |
| 83 | + sh "make manual" |
| 84 | + archiveArtifacts 'doc/*.pdf' |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments