Last change
on this file was c488cf0, checked in by Peter A. Buhr <pabuhr@…>, 9 days ago |
test push
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[cc5544a] | 1 | #!groovy
|
---|
| 2 |
|
---|
[5186e327] | 3 | import groovy.transform.Field
|
---|
| 4 |
|
---|
[0a10dc8] | 5 | // Globals
|
---|
[fae93a40] | 6 | @Field def BuildDir = null
|
---|
| 7 | @Field def SrcDir = null
|
---|
| 8 | @Field def RemoteRepo = ''
|
---|
| 9 | @Field def ArchiveUrl = ''
|
---|
[cc5544a] | 10 |
|
---|
[0a10dc8] | 11 | // Local variables
|
---|
| 12 | def err = null
|
---|
| 13 | def log_needed = false
|
---|
[cc5544a] | 14 |
|
---|
[0a10dc8] | 15 | node {
|
---|
[fae93a40] | 16 | BuildDir = pwd tmp: true
|
---|
| 17 | SrcDir = pwd tmp: false
|
---|
| 18 | RemoteRepo = 'git@github.com:cforall/cforall.git'
|
---|
| 19 | ArchiveUrl = 'https://cforall.uwaterloo.ca/jenkins/job/Cforall_Distribute_Ref/lastSuccessfulBuild/artifact/*zip*/archive.zip'
|
---|
[cc5544a] | 20 | currentBuild.result = "SUCCESS"
|
---|
| 21 |
|
---|
[0a10dc8] | 22 | // Wrap build to add timestamp to command line
|
---|
[cc5544a] | 23 | wrap([$class: 'TimestamperBuildWrapper']) {
|
---|
| 24 | PrepRepo();
|
---|
| 25 | def name = GetArchive();
|
---|
| 26 | PushRepo(name);
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | def GetTarName() {
|
---|
| 31 | def files = findFiles(glob: 'archive/cfa-cc-*.tar.gz')
|
---|
| 32 | echo "found: ${files[0].name}"
|
---|
| 33 | return files[0].name - '.tar.gz';
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | def PrepRepo() {
|
---|
| 37 | stage('Clone') { // for display purposes
|
---|
| 38 | dir (BuildDir) {
|
---|
| 39 | sh 'rm -rf *'
|
---|
[c488cf0] | 40 | sshagent (credentials: ['github_sep2025']) {
|
---|
[cc5544a] | 41 | sh "git clone --bare ${RemoteRepo} repo"
|
---|
| 42 | }
|
---|
| 43 | dir ('repo') {
|
---|
| 44 | sh "mkdir .git"
|
---|
| 45 | sh "mv * .git"
|
---|
| 46 | sh "git init"
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | def GetArchive() {
|
---|
| 53 | def tarball
|
---|
| 54 | stage('Unzip') { // for display purposes
|
---|
| 55 | dir (BuildDir) {
|
---|
| 56 | sh "wget -q ${ArchiveUrl}"
|
---|
| 57 | sh "unzip archive.zip"
|
---|
| 58 | tarball = GetTarName();
|
---|
| 59 | sh "tar -xzf archive/${tarball}.tar.gz"
|
---|
| 60 | sh "mv ${tarball}/* repo/."
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | return tarball
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | def PushRepo(name) {
|
---|
| 67 | stage('Push') { // for display purposes
|
---|
| 68 | dir ("${BuildDir}/repo") {
|
---|
| 69 | sh "git add -A"
|
---|
| 70 | sh "git status"
|
---|
| 71 | sh "git diff-index --quiet HEAD || git commit -m 'Push from build machine: ${name}'"
|
---|
[c488cf0] | 72 | sshagent (credentials: ['github_sep2025']) {
|
---|
[cc5544a] | 73 | sh "git push origin master"
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.