diff --git a/scripts/1clickservice.groovy b/scripts/1clickservice.groovy index 10f521e..c1ed771 100644 --- a/scripts/1clickservice.groovy +++ b/scripts/1clickservice.groovy @@ -103,38 +103,51 @@ pipeline { script { //there's no "if" "step" so any "if" must be in a "script" step if(database){ sh """#!/bin/bash + pushd ${servicename} dbstartline=\$(sed -n '/---dbstart---/=' Jenkinsfile) dbendline=\$(sed -n '/---dbend---/=' Jenkinsfile) - echo \"yes db\" - sed -i -e '\${dbstartline}d;\${dbendline}d;' Jenkinsfile + echo \"yes db. \${dbstartline} and \${dbendline}\" + + sed -ie \"\${dbstartline}d;\${dbendline}d\" Jenkinsfile + echo "114" databasecredsid=\$(uuidgen) - - CRUMB=\$(curl -s \"http://${env.JENKINS_USR}:'${env.JENKINS_PSW}'@alloces.lan:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)\") + echo "116: notice that -s won't happen until line 123" + urlGetData=\"crumbIssuer/api/xml\\?xpath=concat\\(//crumbRequestField,\\":\\",//crumb\\)\"\" + echo "118" + echo \"\${urlGetData}\" + echo "120" + sleep 1 + echo "122" + echo \"curl -s \"http://${env.JENKINS_USR}:\'${env.JENKINS_PSW}\'@alloces.lan:8080/\${urlGetData}\" + echo "123" + curl -s \"http://${env.JENKINS_USR}:\'${env.JENKINS_PSW}\'@alloces.lan:8080/\${urlGetData}\" + + CRUMB=\$(curl -s \"http://${env.JENKINS_USR}:\'${env.JENKINS_PSW}\'@alloces.lan:8080/\${urlGetData}\") echo \$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/greyn%20services/createCredentials' \ + 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/greyn%20services/createCredentials\" \ --data-urlencode 'json={ "": "0", "credentials": { "scope": "GLOBAL", "id": "\$databasecredsid", - "secret": "Host=${targetHost};Database=${servicename};Username=${servicename};Password=${env.pw_productiondatabase};IncludeErrorDetail=true;", + "secret": "\"Host=${targetHost};Database=${servicename};Username=${servicename};Password=${env.pw_productiondatabase};IncludeErrorDetail=true;\"", "description": "database connection string", "\$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl" } }' - sed -i 's/productiondatabase_connectionString=creds/productiondatabase_connectionString=credentials('\$databasecredsid')/' Jenkinsfile + sed -ie 's/productiondatabase_connectionString=creds/productiondatabase_connectionString=credentials('\$databasecredsid')/\' Jenkinsfile git add . - git commit -m "set up for database" + git commit -m \"set up for database\" """ } else{ sh """#!/bin/bash echo \"no db\" pushd ${servicename} - sed -i -e '\${dbstartline},\${dbendline}d;' Jenkinsfile + sed -i '\${dbstartline},\${dbendline}d;' Jenkinsfile git add . git commit -m "stripped database lines" """