source: Jenkins/Promote@ 4be9a14

Last change on this file since 4be9a14 was 4be9a14, checked in by Peter A. Buhr <pabuhr@…>, 3 months ago

update groovy scripts to suppress warning messages

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