Compare commits
2 Commits
a672887719
...
519990ba19
Author | SHA1 | Date | |
---|---|---|---|
519990ba19 | |||
da1b6aaed8 |
@ -26,6 +26,27 @@ pipeline {
|
||||
error("servicename cannot have spaces. try dashes.")
|
||||
}
|
||||
|
||||
|
||||
sh """#!/bin/bash
|
||||
function testcmd(){
|
||||
if ! command -v \$1 2>&1 >/dev/null
|
||||
then
|
||||
echo "this agent doesn't have \$1"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
testcmd mktemp
|
||||
testcmd curl
|
||||
testcmd git
|
||||
testcmd sed
|
||||
testcmd ssh
|
||||
testcmd ssh-keyscan
|
||||
testcmd ssh-keygen
|
||||
testcmd scp
|
||||
testcmd jq
|
||||
"""
|
||||
|
||||
switch (targetHost) {
|
||||
case "alloces.lan":
|
||||
SUDOER_USR = SUDOER_ALLOCES_USR
|
||||
@ -132,7 +153,8 @@ pipeline {
|
||||
"\$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
|
||||
}
|
||||
}'
|
||||
sed -i 's/productiondatabase_connectionString=creds/productiondatabase_connectionString=credentials('\$databasecredsid')/\' Jenkinsfile
|
||||
credsStr="productiondatabase_connectionString=credentials(\\"\$databasecredsid\\")"
|
||||
sed -i "s/productiondatabase_connectionString=creds/\$credsStr/" Jenkinsfile
|
||||
|
||||
rm cookies.txt
|
||||
git add .
|
||||
@ -197,13 +219,16 @@ pipeline {
|
||||
"\$class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
|
||||
}
|
||||
}'
|
||||
privatekeycontent=
|
||||
|
||||
sed -i 's/linuxServiceAccount=creds/linuxServiceAccount=credentials('${env.usernameCredsId}')/' Jenkinsfile
|
||||
sed -i 's/targetHost=string/targetHost="${targetHost}"/' Jenkinsfile
|
||||
|
||||
rm cookies.txt
|
||||
pushd ${servicename}
|
||||
|
||||
linuxServiceAccountStr="linuxServiceAccount=credentials(\\"\$usernameCredsId\\")"
|
||||
sed -i "s/linuxServiceAccount=creds/\$linuxServiceAccountStr/" Jenkinsfile
|
||||
sed -i 's/targetHost=string/targetHost="${targetHost}"/' Jenkinsfile
|
||||
git add .
|
||||
git commit -m "linux account, service host"
|
||||
|
||||
git -c core.sshCommand="ssh -i '${PK}'\" push
|
||||
"""
|
||||
}
|
||||
@ -270,13 +295,15 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
post {
|
||||
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> :("
|
||||
}
|
||||
success {
|
||||
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!'
|
||||
matrixSendMessage https:true, hostname: 'greyn.club', port:8448, accessTokenCredentialsId: '040b63d1-2f14-4692-badb-114bddd7c5a5', roomId: '!QmOCACetHdGDlNFsZP:greyn.club', body: "${servicename} ready to go on ${targetHost}. username: ${servicename}, password: ${env.pw_linuxserviceaccount}. if db, prod db pw: ${env.pw_productiondatabase} and dev pw: ${env.pw_developmentdatabase}"
|
||||
//TODO: archiveArtifacts the password data, then store them somewhere
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue
Block a user