forked from tekdi/pratham-saral-school-prepareness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-backend
40 lines (35 loc) · 1.88 KB
/
Jenkinsfile-backend
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
#!groovy
node('server_build_slave') {
try {
stage('Checkout'){
checkout scm
}
stage('compress build folder')
withCredentials([usernamePassword(credentialsId: 'anuvaad-docker-hub-credentials', passwordVariable: 'dockerhub_pass', usernameVariable: 'dockerhub_user')])
{
sh '''
cd v1.0/backend
if [ -f "$(pwd)/build" ]
then
sudo rm -rf $(pwd)/build
fi
if [ $( docker ps -q -f status=exited --filter "name=$JOB_BASE_NAME" ) ]
then
docker rm "$JOB_BASE_NAME"
fi
commit_id=${BUILD_ID}-$(git rev-parse --short HEAD)
echo $commit_id> commit_id.txt
cp ../../specs/v1.5/swagger-saral-maintenance.yaml ./src
cp ../../specs/v1.5/swagger-saral-frontend.yaml ./src
cp ../../specs/v1.5/swagger-saral-apidoc.yaml ./src
docker build -t anuvaadio/$image_name:$image_tag .
docker login -u $dockerhub_user -p $dockerhub_pass
docker push anuvaadio/$image_name:$image_tag
'''
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
}