From c3eda11c05ec66c03ffee6dc22ffa19e21f3c9dd Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 13 Dec 2024 21:06:44 -0500 Subject: [PATCH] try and write in database string --- scripts/1clickservice.groovy | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/1clickservice.groovy b/scripts/1clickservice.groovy index 7db94bc..3e37d10 100644 --- a/scripts/1clickservice.groovy +++ b/scripts/1clickservice.groovy @@ -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 sed -i "s/\\"DBConnectionString\\":\\"[^"]*\\"/\\"DBConnectionString\\":\\"\$databaseString\\"/g" appsettings.json """ @@ -178,6 +180,7 @@ pipeline { ssh-keygen -t ed25519 -f "${servicename}-ssh" -N "" privatekeycontent=\$(cat ${servicename}-ssh) + 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 @@ -267,6 +270,12 @@ pipeline { } stage("initial service setup"){ steps{ + sh """#!/bin/bash + pushd ${servicename} + scp -i \"${servicename}-ssh\" appsettings.json ${servicename}@${targetHost}:dist/appsettings.json + popd + """ + sh """#!/bin/bash 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