This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkinsfile
87 lines (75 loc) · 3.09 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!groovy
pipeline {
agent {
label 'docker-maven-slave'
}
triggers {
githubPush()
}
parameters {
string(name: 'modelname', defaultValue: '<your rasa url>')
}
environment {
BUILD_VERSION = "$currentBuild.number".trim()
BRANCH = "$BRANCH_NAME"
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
stages {
stage ('Build and Deploy Chatbot/FAQ') {
steps {
withCredentials([usernamePassword(credentialsId: '<Jenkins credentials username>', passwordVariable: '<Jenkins credentials password>', usernameVariable: 'username')]) {
sh """
git config --global user.name "<your name>"
git config --global user.email "<your email>"
export CURRENT_BRANCH=master
export GITHUB_HOST=<your github host>
git clone https://${username}:${password}@github.com/<org>/<repo>.git
cd <into your repo folder>
git remote -v
"""
}
withCredentials([usernamePassword(credentialsId: '<Jenkins credentials username>', passwordVariable: '<Jenkins credentials password>', usernameVariable: 'username')]) {
sh '''
echo "Creating Build ID"
echo ${BUILD_VERSION} >> modelname.txt
echo "Create and Update Virtual Env"
wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86.sh -O miniconda.sh
bash miniconda.sh -b -p $PWD/miniconda
export PATH="$PWD/miniconda/bin:$PATH"
conda create -y -q -n chatscript python=3
source activate chatscript
pip install --upgrade pip
pip install pandas
pip install requests
pip install tensorflow
pip install rasa
conda install -c conda-forge hub
git config --global --add hub.host github.com
echo "Run File Creation Script"
python chatscript.py
echo "Train Models"
python rasatrain.py
ls -d -l models
curl -k -F "model=@models/\"${BUILD_VERSION}.tar.gz\"" "<your rasa url + token>"
echo "Upload Rasa Model"
python rasaUpload.py
echo "Start GIT Workflow"
cd ./<Your cloned repo>
git checkout -b "Jenkins-Build-\"${BUILD_VERSION}\""
git remote add upstream <your github repo here>
git pull upstream master
cd ..
cp faq.mdx ./<your cloned repo faq location> -f
cd ./<Your cloned repo base location>
git add <directory to your FAQ>
git commit -m "Automated FAQ Update"
git push --set-upstream origin Jenkins-Build-${BUILD_VERSION}
echo "\"${username}\" \"${password}\"" hub pull-request --base <Your repo>:master --head <Username>:automated-jenkins --message Automated-Jenkins-Build
'''
}
}
}
}
}