generates gitea project from template :)
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good

jq is suffering shell-quoting issues.
This commit is contained in:
adam 2024-11-21 13:02:37 -05:00
parent 7130f70aaf
commit 816bcff09d

View File

@ -3,16 +3,17 @@ pipeline {
parameters {
string(name: 'servicename', description: "service name")
string(name: 'svcdesc', description: "service description")
string(name: 'targetHost', description: "system to live on", defaultValue: "alloces.lan")
string(name: 'targetHost', description: "system to live on", defaultValue: "moloryb.lan")
booleanParam(name: 'database', description: "service has a database", defaultValue: true)
}
environment {
pw_linuxserviceaccount=""
pw_productiondatabase=""
pw_developmentdatabase=""
SUDOER=credentials('') //going to be set based on target host
//pw_linuxserviceaccount=""
//pw_productiondatabase=""
//pw_developmentdatabase=""
//SUDOER=credentials('') //going to be set based on target host
SUDOERSSH=credentials('2c48e1a9-22b2-455c-9959-6b29e86d3fb5')
JENKINS=credentials('68391381-e095-4b47-b956-d23055b0808e')
JENKINS=credentials('f1192e74-dfe0-402f-a189-703482d914fe')
GITEATOKEN = credentials('d0e86441-2157-405f-8539-a9a9010c6ecf')
}
stages {
stage("environment setup") {
@ -45,15 +46,12 @@ pipeline {
}
}
stage("gitea project"){
environment {
GITEA = credentials('0bd7c8f5-046c-44b9-9c77-7a28a219ae31')
}
steps{
sh """
curl -X 'POST' \
'https://gitea.arg.rip/api/v1/repos/greyn/_service-template/generate' \
'https://gitea.arg.rip/api/v1/repos/greyn/_template-service/generate' \
-H 'accept: application/json' \
-H 'Authorization: token $GITEA_PSW' \
-H 'Authorization: token ${env.GITEATOKEN}' \
-H 'Content-Type: application/json' \
-d '{
"description": "${svcdesc}",
@ -72,19 +70,22 @@ pipeline {
}
stage("jenkins pipeline"){
steps{
sh """
curl -X POST -L --user ${env.JENKINS_USR}:${env.JENKINS_PSW} \
alloces.lan:8080/job/gitea.arg.rip/build
"""
//the bad news is that it looks like it's not allowed to trigger just any old job remotely
//the good news is that this seems to pick it up pretty reliably
//sh """
// curl -X POST -L --user ${env.JENKINS_USR}:${env.JENKINS_PSW} \
// alloces.lan:8080/job/gitea.arg.rip/build
// """
timeout(time: 5, unit: 'MINUTES') {
sh """
strRes=""
while [ -z "$strRes" ];
while [ -z "\$strRes" ];
do
sleep 5;
strRes=\$(curl -X GET -s -u ${env.JENKINS_USR}:${env.JENKINS_PSW} \
alloces.lan:8080/job/gitea.arg.rip/api/json | jq '.jobs.[] | select(.name=="${env.servicename}")')
strRes=\$(curl -X GET -s -u ${env.JENKINS_USR}:'${env.JENKINS_PSW}' \
alloces.lan:8080/job/gitea.arg.rip/api/json \
| jq ".jobs.[] | select(.name==\"${env.servicename}\")")
done
"""
}
@ -256,11 +257,10 @@ pipeline {
}
post {
failure {
matrixSendMessage hostname: 'https://greyn.club:8448', accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: '1-click service failed :('
matrixSendMessage https:true, hostname: 'greyn.club', port:8448, accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: '1-click service failed :(', formattedBody: "1-click service <b>failed</b> :("
}
success {
matrixSendMessage hostname: 'https://greyn.club:8448', accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: '1-click service success! go pick up the credentials!'
matrixSendMessage https:true, hostname: 'greyn.club', port:8448, accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: '1-click service success! go pick up the credentials!', formattedBody: '1-click service success! go pick up the credentials!'
//TODO: archiveArtifacts the password data, then store them somewhere
}
}