Compare commits

..

No commits in common. "159a0027ff50baa7e6d21cec0e75153f52dccf64" and "90091205467d38ab0c9e7b267f5c1c5821a9dc46" have entirely different histories.

2 changed files with 74 additions and 91 deletions

View File

@ -285,6 +285,7 @@ pipeline {
} }
} }
} }
/*
post { post {
failure { failure {
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> :(" 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> :("
@ -294,4 +295,5 @@ pipeline {
//TODO: archiveArtifacts the password data, then store them somewhere //TODO: archiveArtifacts the password data, then store them somewhere
} }
} }
*/
} }

View File

@ -5,109 +5,90 @@ pipeline {
string(name: 'videodesc', description: "video description") string(name: 'videodesc', description: "video description")
} }
environment { environment {
JENKINSONGITEA=credentials('d0e86441-2157-405f-8539-a9a9010c6ecf') GITEATOKEN = credentials('d0e86441-2157-405f-8539-a9a9010c6ecf')
JENKINSONMATRIXTOKEN=credentials('17d18fd7-29eb-4957-9532-ce42aaa9b4ec') JENKINSMATRIX=credentials('040b63d1-2f14-4692-badb-114bddd7c5a5')
} }
stages { stages {
stage("environment setup") { stage("environment setup") {
steps{ steps{
script{ script{
if (videoname.isEmpty()) { if (videoname.isEmpty()) {
error("videoname mandatory") error("videoname mandatory")
} }
if (videoname.contains(' ')) { if (videoname.contains(' ')) {
error("videoname cannot have spaces. try dashes.") error("videoname cannot have spaces. try dashes.")
} }
} }
} }
} }
stage("create gitea project"){ stage("create gitea project"){
steps{ steps{
script{ sh """
env.giteaCreateEvent=sh(returnStdout: true, script: """ curl -X 'POST' \
curl -X 'POST' \ 'https://gitea.arg.rip/api/v1/repos/beefhavers/_videotemplate/generate' \
'https://gitea.arg.rip/api/v1/repos/beefhavers/_videotemplate/generate' \ -H 'accept: application/json' \
-H 'accept: application/json' \ -H 'Authorization: token ${env.GITEATOKEN}' \
-H 'Authorization: token ${env.JENKINSONGITEA}' \ -H 'Content-Type: application/json' \
-H 'Content-Type: application/json' \ -d '{
-d '{ "description": "${videodesc}",
"description": "${videodesc}", "git_content": true,
"git_content": true, "git_hooks": true,
"git_hooks": true, "labels": true,
"labels": true, "name": "${videoname}",
"name": "${videoname}", "owner": "beefhavers",
"owner": "beefhavers", "private": false,
"private": false, "protected_branch": true,
"protected_branch": true, "topics": true,
"topics": true, "webhooks": true
"webhooks": true }'
}' """
""").trim()
if (!env.giteaCreateEvent?.trim()) {
error "couldn't make gitea repo, apparently"
}
}
} }
} }
stage("create matrix room"){ stage("create matrix room"){
steps{ steps{
script{ env.roomId=sh(returnStdout: true, script: """curl -X 'POST' \
env.roomcreationevent=sh(returnStdout: true, script: """ 'https://greyn.club:8448/_matrix/client/v3/createRoom' \
curl -X 'POST' \ -H 'accept: application/json' \
'https://greyn.club:8448/_matrix/client/v3/createRoom' \ -H 'Authorization: Bearer ${JENKINSMATRIX}}' \
-H 'accept: application/json' \ -H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${JENKINSONMATRIXTOKEN}' \ -d '{
-H 'Content-Type: application/json' \ "creation_content": {
-d '{ "m.federate": false
"creation_content": { },
"m.federate": false "name": "${videoname}",
}, "preset": "public_chat",
"name": "${videoname}", "invite": ["@adam:greyn.club", "@gitea:greyn.club"],
"preset": "public_chat", "topic": "[link to gitea project]"
"invite": ["@adam:greyn.club", "@gitea:greyn.club"], }' | jq .room_id
"topic": "[link to gitea project]" """).trim()
}'
"""
).trim()
if (!env.roomcreationevent?.trim()) {
error "couldn't make matrix room, apparently"
}
echo "roomcreationevent:"
echo env.roomcreationevent
env.room_id = sh(returnStdout: true, script: "${env.roomcreationevent} | jq .room_id").trim()
if(!env.room_id?.trim()){
error "couldn't make matrix room, apparently"
}
}
}
} }
stage("link gitea webhook"){ stage("link gitea webhook"){
steps{ steps{
sh """ sh """
curl -X 'GET' 'https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks' \ curl -X 'GET' 'https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks' \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H 'authorization: token ${env.JENKINSONGITEA}' \ -H 'authorization: token ${env.GITEATOKEN}' \
>reporesponse.json >reporesponse.json
""" """
sh """ sh """
curl -X 'PATCH' 'https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks' \ curl -X 'PATCH' 'https://gitea.arg.rip/api/v1/repos/beefhavers/${videoname}/hooks' \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H 'authorization: token ${env.JENKINSONGITEA}' \ -H 'authorization: token ${env.GITEATOKEN}' \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{ -d '{
"active": true, "active": true,
"authorization_header": \$(cat reporesponse.json | jq .[0].authorization_header), "authorization_header": $$(cat reporesponse.json | jq .[0].authorization_header),
"branch_filter": "*", "branch_filter": "*",
"config": { "config": {
"content_type": "json", "content_type": "json",
"url": "https://greyn.club:8448/_matrix/client/r0/rooms/\$(echo ${env.room_id} | sed 's/!/%21/')/send/m.room.message" "url": "https://greyn.club:8448/_matrix/client/r0/rooms/$$(echo ${env.roomId} | sed 's/!/%21/')/send/m.room.message"
}, },
"events": \$(cat reporesponse.json | jq .[0].events) "events": $$(cat reporesponse.json | jq .[0].events)
}' }'
""" """
} }
} }
} }
} }