Last change
on this file since 402a1e7 was
60380a1,
checked in by caparsons <caparson@…>, 20 months ago
|
trying to get Jenkins Promote to work with new credentials
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | #!groovy |
---|
2 | |
---|
3 | node { |
---|
4 | // Globals |
---|
5 | BuildDir = pwd tmp: true |
---|
6 | SrcDir = pwd tmp: false |
---|
7 | RemoteRepo = 'git@github.com:cforall/cforall.git' |
---|
8 | ArchiveUrl = 'https://cforall.uwaterloo.ca/jenkins/job/Cforall_Distribute_Ref/lastSuccessfulBuild/artifact/*zip*/archive.zip' |
---|
9 | |
---|
10 | // Local variables |
---|
11 | def err = null |
---|
12 | def log_needed = false |
---|
13 | |
---|
14 | currentBuild.result = "SUCCESS" |
---|
15 | |
---|
16 | //Wrap build to add timestamp to command line |
---|
17 | wrap([$class: 'TimestamperBuildWrapper']) { |
---|
18 | |
---|
19 | PrepRepo(); |
---|
20 | |
---|
21 | def name = GetArchive(); |
---|
22 | |
---|
23 | PushRepo(name); |
---|
24 | } |
---|
25 | |
---|
26 | } |
---|
27 | |
---|
28 | def 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 | |
---|
34 | def PrepRepo() { |
---|
35 | stage('Clone') { // for display purposes |
---|
36 | dir (BuildDir) { |
---|
37 | sh 'rm -rf *' |
---|
38 | sshagent (credentials: ['git_key_mar27']) { |
---|
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 | |
---|
50 | def 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 | |
---|
62 | return tarball |
---|
63 | } |
---|
64 | |
---|
65 | def PushRepo(name) { |
---|
66 | stage('Push') { // for display purposes |
---|
67 | dir ("${BuildDir}/repo") { |
---|
68 | sh "git add -A" |
---|
69 | sh "git status" |
---|
70 | sh "git diff-index --quiet HEAD || git commit -m 'Push from build machine: ${name}'" |
---|
71 | sshagent (credentials: ['git_key_mar27']) { |
---|
72 | sh "git push origin master" |
---|
73 | } |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.