|
1 |
| -def repos = [ |
2 |
| - 'cfengine': [ |
3 |
| - 'core', |
4 |
| -'enterprise', |
5 |
| -'nova', |
6 |
| -'masterfiles' |
7 |
| - ], |
8 |
| - 'NorthernTechHQ': [ |
9 |
| -['nt-docs': 'main'], |
10 |
| - ] |
11 |
| -] |
| 1 | +pipeline { |
| 2 | + agent any |
12 | 3 |
|
13 |
| -rev_ref_description="Use NUMBER or 'pull/NUMBER/merge' for pull request (it's merged version, THIS DOESN'T MERGE THE PR) or 'pull/NUMBER/head' to run the tests on the non-merged code. Special syntax 'tag:SOME_TAG' can be used to use a tag as a revision." |
14 |
| - |
15 |
| -/* comments OK? |
16 |
| -TODO: |
17 |
| -- [ ] provide a way of specifying refs in other repos, like a coordinated multi-pr build |
18 |
| -*/ |
19 |
| -properties([ |
20 |
| - buildDiscarder(logRotator(daysToKeepStr: '10')), |
21 |
| - parameters([ |
22 |
| - string(name: 'CORE_REV', defaultValue: 'master'), |
23 |
| - string(name: 'NOVA_REV', defaultValue: 'master'), |
24 |
| - string(name: 'ENTERPRISE_REV', defaultValue: 'master'), |
25 |
| - string(name: 'MASTERFILES_REV', defaultValue: 'master'), |
26 |
| - string(name: 'DOCS_REV', defaultValue: 'master'), |
27 |
| - string(name: 'DOCS_BRANCH', defaultValue: 'master', description: 'Where to upload artifacts - to http://buildcache.cloud.cfengine.com/packages/build-documentation-$DOCS_BRANCH/ and https://docs.cfengine.com/docs/$DOCS_BRANCH/'), |
28 |
| - string(name: 'PACKAGE_JOB', defaultValue: 'testing-pr', description: 'where to take CFEngine HUB package from, a dir at http://buildcache.cloud.cfengine.com/packages/'), |
29 |
| - string(name: 'USE_NIGHTLIES_FOR', defaultValue: 'master', description: 'branch whose nightlies to use (master, 3.18.x, etc) - will be one of http://buildcache.cloud.cfengine.com/packages/testing-pr/jenkins-$USE_NIGHTLIES_FOR-nightly-pipeline-$NUMBER/'), |
30 |
| - string(name: 'NT_DOCS_REV', defaultValue: 'main', description: "${rev_ref_description}") |
31 |
| - ]) |
32 |
| -]) |
33 |
| - |
34 |
| -// clean workspace on Success (specify all the OTHER cases as false) |
35 |
| - |
36 |
| -node('CONTAINERS') { |
37 |
| - dir('documentation') { |
38 |
| - checkout scm |
39 |
| - } |
40 |
| - |
41 |
| - stage('Checkout repositories') { |
42 |
| - // Note that stages created this way are NOT available for "Restart from Stage" in jenkins UI |
43 |
| -repos.each { org -> |
44 |
| - println("organization is ${org.key}") |
45 |
| - org.value.each { repo_data -> |
46 |
| - if (!(repo_data instanceof Map)) { |
47 |
| - repo_data=["${repo_data}": "master"] |
48 |
| - } |
49 |
| - repo_data.each{ repo, branch -> |
50 |
| - stage("Checkout ${repo}") { |
51 |
| - sh "mkdir -p ${repo}" |
52 |
| - dir ("${repo}") |
53 |
| - { |
54 |
| - git branch: "${branch}", |
55 |
| - credentialsId: 'autobuild', |
56 |
| - url: "[email protected]:${org.key}/${repo}" |
57 |
| - } |
| 4 | + stages { |
| 5 | + stage('Check environment'){ |
| 6 | + steps { |
| 7 | + sh 'env' |
58 | 8 | }
|
59 | 9 | }
|
60 | 10 | }
|
61 | 11 | }
|
62 |
| -} // for the stage |
63 |
| - stage('See what cloned') { |
64 |
| - sh 'pwd' |
65 |
| - sh 'whoami' |
66 |
| - sh 'ls -la' |
67 |
| - sh 'cd documentation; git log --oneline | head -n1' |
68 |
| - } |
69 |
| - withEnv([ |
70 |
| -'BRANCH=master', |
71 |
| -'PACKAGE_JOB=testing-pr', |
72 |
| -'PACKAGE_UPLOAD_DIRECTORY=jenkins-master-nightly-pipeline-152', |
73 |
| -'PACKAGE_BUILD=1', |
74 |
| -]) { |
75 |
| - stage('Build') { |
76 |
| - // hard code for now, won't actually publish yet so not too big of a deal |
77 |
| - sh 'bash -x documentation/generator/build/run.sh' |
78 |
| - archiveArtifacts artifacts: 'output/', fingerprint: true |
79 |
| - } |
80 |
| -} |
81 |
| -stage('Publish') { |
82 |
| - sshPublisher(publishers: [sshPublisherDesc(configName: 'buildcache.cloud.cfengine.com', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''set -x |
83 |
| -export WRKDIR=`pwd` |
84 |
| -
|
85 |
| -mkdir -p upload |
86 |
| -mkdir -p output |
87 |
| -
|
88 |
| -# find two tarballs |
89 |
| -archive=`find upload -name \'cfengine-documentation-*.tar.gz\'` |
90 |
| -tarball=`find upload -name packed-for-shipping.tar.gz` |
91 |
| -echo "TARBALL: $tarball" |
92 |
| -echo "ARCHIVE: $archive" |
93 |
| -
|
94 |
| -# unpack $tarball |
95 |
| -cd `dirname $tarball` |
96 |
| -tar zxvf packed-for-shipping.tar.gz |
97 |
| -rm packed-for-shipping.tar.gz |
98 |
| -
|
99 |
| -# move $archive to the _site |
100 |
| -mv $WRKDIR/$archive _site |
101 |
| -
|
102 |
| -ls -la |
103 |
| -cd - |
104 |
| -
|
105 |
| -ls -la upload |
106 |
| -
|
107 |
| -# note: this triggers systemd job to AV-scan new files |
108 |
| -# and move them to proper places |
109 |
| -mv upload/* output |
110 |
| -''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'upload/$BUILD_TAG/build-documentation-$DOCS_BRANCH/$BUILD_TAG/', remoteDirectorySDF: false, removePrefix: '', sourceFiles: 'output/')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) |
111 |
| -} |
112 |
| - |
113 |
| -stage('Clean workspace on Success') { |
114 |
| - cleanWs() |
115 |
| -} |
116 |
| -} |
0 commit comments