source: Jenkins/Promote@ 0a10dc8

Last change on this file since 0a10dc8 was 0a10dc8, checked in by Peter A. Buhr <pabuhr@…>, 2 months ago

update groovy scripts to suppress warning messages

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