forked from bsc-wdc/dislib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (64 loc) · 2.34 KB
/
Jenkinsfile
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
59
60
61
62
63
64
65
def setGithubCommitStatus(state, description) {
withEnv(["STATE=$state", "DESCRIPTION=$description"]) {
withCredentials([string(credentialsId: 'Compsupescalar Github secret token', variable: 'GITHUB_TOKEN')]) {
sh 'curl -H "Authorization: token $GITHUB_TOKEN" -X POST \
--data "{\\"state\\": \\"$STATE\\", \\"description\\": \\"$DESCRIPTION\\", \
\\"target_url\\": \\"${BUILD_URL}\\", \\"context\\": \\"continuous-integration/jenkins\\" }" \
--url https://api.github.com/repos/bsc-wdc/dislib/statuses/${GIT_COMMIT}'
}
}
}
pipeline {
options {
timeout(time: 3, unit: 'HOURS')
}
agent {
node {
label 'Docker'
}
}
stages {
stage('build') {
steps {
setGithubCommitStatus('pending', 'The Jenkins build is in progress')
sh 'git lfs pull origin'
sh 'docker rm -f dislib &> /dev/null || true'
sh 'docker rmi -f bscwdc/dislib &> /dev/null || true'
sh 'docker build --pull --no-cache --tag bscwdc/dislib .'
sh '''#!/bin/bash
docker run $(bash <(curl -s https://codecov.io/env)) -d --name dislib bscwdc/dislib'''
}
}
stage('test') {
steps {
sh 'docker exec dislib /dislib/run_ci_checks.sh'
}
}
stage('deploy') {
when {
branch 'master'
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId:'dockerhub_compss', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh 'docker login -u "$USERNAME" -p "$PASSWORD"'
}
sh 'docker tag bscwdc/dislib bscwdc/dislib:latest'
sh 'docker push bscwdc/dislib:latest'
}
}
}
post{
always {
sh 'docker exec dislib /dislib/bin/print_tests_logs.sh'
sh 'docker images'
sh 'docker rm -f dislib &> /dev/null || true'
sh 'docker rmi -f bscwdc/dislib &> /dev/null || true'
}
success {
setGithubCommitStatus('success', 'Build Successful')
}
failure {
setGithubCommitStatus('failure', 'Build Failure')
}
}
}