-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
58 lines (58 loc) · 1.94 KB
/
Jenkinsfile
File metadata and controls
58 lines (58 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// https://www.jenkins.io/doc/book/pipeline/docker/
pipeline {
agent {
docker { image 'piersfinlayson/build-amd64:0.3.2' }
}
stages {
stage('Clone') {
steps {
withCredentials([usernamePassword(credentialsId: 'github.packom', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh '''
cd ~/builds && \
git clone https://packom:$PASSWORD@github.com/packom/mbus-httpd && \
cd mbus-httpd && \
echo `awk '/^version / {print $3;}' Cargo.toml | sed 's/"//g'` > /tmp/version && \
echo "Current version is:" && \
cat /tmp/version
'''
}
}
}
stage('Build') {
steps {
sh '''
cd ~/builds/mbus-httpd && \
cargo build
'''
}
}
stage('Test') {
steps {
sh '''
cd ~/builds/mbus-httpd && \
cargo test
'''
}
}
stage('Publish') {
steps {
withCredentials([usernamePassword(credentialsId: 'crates.packom', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh '''
cd ~/builds/mbus-httpd && \
CURV=$(cat /tmp/version) && \
echo `cargo search mbus | awk '/^mbus / {print $3;}' | sed 's/"//g'` > /tmp/old_version && \
echo "Old version is:" && \
cat /tmp/old_version && \
OLDV=$(cat /tmp/old_version) && \
if [ $CURV != $OLDV ]
then
cargo publish --token $PASSWORD
else
echo "No changes to publish"
fi
'''
}
}
}
}
}