source: Jenkins/Promote@ 8730e57

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

update groovy scripts to suppress warning messages

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