Compare commits

...

3 Commits

Author SHA1 Message Date
51b87b720b uhhh pretty sure it works
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
2024-12-18 19:47:33 -05:00
41045a0973 connection string, ssh key 2024-12-13 22:49:00 -05:00
c3eda11c05 try and write in database string 2024-12-13 21:06:44 -05:00

View File

@ -128,20 +128,19 @@ pipeline {
pushd ${servicename}
databaseString="Host=${targetHost};Database=${servicename};Username=${servicename};Password=${env.pw_productiondatabase};IncludeErrorDetail=true;"
databasecredsid=\$(uuidgen)
httpBasicAuth=\"http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/\"
echo \"\${httpBasicAuth}\"
urlGetData=\"crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\\":\\",//crumb)\"
CRUMB=\$(curl -s -c cookies.txt \"\${httpBasicAuth}\${urlGetData}\")
echo "crumb anyway. \$CRUMB"
curl -H \$CRUMB -X POST \"http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/job/gitea.arg.rip/job/${servicename}/credentials/store/folder/domain/_/createCredentials\" \
--data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "'"\$databasecredsid"'",
"secret": "Host=${targetHost};Database=${servicename};Username=${servicename};Password=${env.pw_productiondatabase};IncludeErrorDetail=true;",
"secret": "\$databaseString",
"description": "database connection string",
"\$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
@ -152,6 +151,9 @@ pipeline {
rm cookies.txt
git add .
git commit -m \"set up for database\"
cp appsettings.sample.json appsettings.json
sed -i "s/\\"DBConnectionString\\" *: *\\"[^\\"]*\\"/\\"DBConnectionString\\":\\"\${databaseString}\\"/" appsettings.json
"""
@ -177,7 +179,10 @@ pipeline {
certCredsId=\$(uuidgen)
ssh-keygen -t ed25519 -f "${servicename}-ssh" -N ""
privatekeycontent=\$(cat ${servicename}-ssh)
privatekeycontent=\$(cat ${servicename}-ssh)\$'\\n'
privatekeycontent="\$privatekeycontent
"
echo "private key content: \$privatekeycontent hopefully newline isn't the issue."
pubkeycontent=\$(cat ${servicename}-ssh.pub)
CRUMB=\$(curl -s 'http://${env.JENKINS_USR}:${env.JENKINS_PSW}@alloces.lan:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
echo \$CRUMB
@ -268,6 +273,9 @@ pipeline {
stage("initial service setup"){
steps{
sh """#!/bin/bash
ssh -i "${servicename}-ssh" -tt ${servicename}@${targetHost} "mkdir -p ~/dist"
scp -i "${servicename}-ssh" ${servicename}/appsettings.json ${servicename}@${targetHost}:~/dist/appsettings.json
ssh -i "${servicename}-ssh" -tt ${servicename}@${targetHost} "mkdir -p ~/.config/systemd/user/"
scp -i "${servicename}-ssh" ${servicename}/${servicename}.service ${servicename}@${targetHost}:~/.config/systemd/user/${servicename}.service