aidgaf-server/Jenkinsfile

59 lines
2.4 KiB
Plaintext
Raw Normal View History

2023-02-15 03:26:12 +00:00
#!/bin/groovy
/* groovylint-disable CompileStatic, DuplicateStringLiteral, LineLength */
2023-02-12 20:22:52 +00:00
pipeline {
agent {
docker {
alwaysPull true
image 'alpine:3.14'
label 'Wrangler1'
args '-u root'
}
}
stages {
2023-02-15 03:26:12 +00:00
stage('Prepare Environment') {
steps {
sh '#!/bin/sh \n' +
2023-02-12 20:22:52 +00:00
'id; apk add docker openrc git'
}
}
2023-02-15 03:26:12 +00:00
stage('Obtain Source') {
2023-02-12 20:22:52 +00:00
steps {
git branch: 'main', url: 'https://git.adamoutler.com/aoutler/aidgaf-server.git'
}
}
stage('Build in docker') {
steps {
// Get some code from a Git repository
2023-02-15 03:26:12 +00:00
sh '#!/bin/sh \n' +
2023-02-12 20:22:52 +00:00
'docker build -t aidgaf .'
}
}
2023-02-15 03:26:12 +00:00
stage('setup credentials') {
steps {
2023-02-12 20:22:52 +00:00
withCredentials([ sshUserPrivateKey(credentialsId: 'dockeruserOn192.168.1.115', keyFileVariable: 'sshkey', usernameVariable: 'user')]) {
2023-02-15 03:26:12 +00:00
sh '#!/bin/sh \n' +
2023-02-12 20:22:52 +00:00
'set +e; docker stop aidgaf-server||echo machine stopped; docker rm aidgaf-server||echo machine does not exist; set -e'
}
}
}
2023-02-15 03:26:12 +00:00
stage('export docker container') {
2023-02-12 20:22:52 +00:00
steps {
2023-02-15 03:26:12 +00:00
sh '#!/bin/sh \n' +
2023-02-12 20:22:52 +00:00
'set +e; docker stop aidgaf-server||echo machine stopped; docker rm aidgaf-server||echo machine does not exist; set -e'
withCredentials([
string(credentialsId: 'OpenAI-API-Token', variable: 'OPEN_AI_TOKEN'),
string(credentialsId: 'PapaHashingSecret', variable: 'PAPA_HASH'),
2023-02-15 03:26:12 +00:00
string(credentialsId: 'PapaAsyncUrl', variable: 'ASYNC_URL'),
2023-02-15 05:03:53 +00:00
sshUserPrivateKey(credentialsId: 'dockeruserOn192.168.1.115', keyFileVariable: 'sshkey')]) {
2023-02-15 03:26:12 +00:00
sh '#!/bin/sh \n' +
'mkdir -p ~/.ssh; cp "$sshkey" ~/.ssh/id_rsa'
sh '#!/bin/sh \n' +
/* groovylint-disable-next-line GStringExpressionWithinString */
2023-02-15 05:03:53 +00:00
'docker run --name=aidgaf-server -eSERVERPORT=8087 -eHOSTNAME=0.0.0.0 -eHASHKEY="${PAPA_HASH}" -eAPIKEY="${OPEN_AI_TOKEN}" -eASYNC_METHOD="PATCH" -eASYNC_URL="${ASYNC_URL}" -p8087:8087 -d --restart=always aidgaf'
}
2023-02-12 20:22:52 +00:00
}
}
}
}