87 lines
2.4 KiB
Plaintext
Executable File
87 lines
2.4 KiB
Plaintext
Executable File
def domainsToCert = [
|
|
|
|
[ false, 'bodypainter.eu', "www", "mail", "stat"],
|
|
[ false, 'themself.eu', "www", "mail", "stat", "massage" ],
|
|
|
|
[ false, "artiks.tk", "www", "mail", "api", "angular", "bodypainter", "themself","arti24"],
|
|
[ false, "arti24.eu", "www", "api", "angular", "ai", "job-finder", "zaklik"]
|
|
// [ false, 'artikus.dynu.net', "mail", "stat", "www", "nextcloud" ]
|
|
]
|
|
|
|
def createCert(domains, repo){
|
|
|
|
echo "Server ENV = ${SERVER_ENV}"
|
|
echo "Cerbot image = ${CERTBOT_IMAGE} "
|
|
echo "CERTIFICATES_FOR = ${CERTIFICATES_FOR} "
|
|
|
|
|
|
def toCreateDomains =[]
|
|
|
|
for( domain in domains ){
|
|
def force = domain[ 0 ]
|
|
def name = domain[ 1 ]
|
|
def fileName = '/_docker_data_/letsencrypt/live/'+name
|
|
if( !force && fileExists( fileName ) ){
|
|
echo "The file('${fileName}') certificate for '${domain}(main:${name})' exists! You should renew it"
|
|
}else{
|
|
echo "File '${fileName}' not exists! or ${force} so create certificate for '${name}'"
|
|
toCreateDomains.add( domain )
|
|
}
|
|
}
|
|
|
|
echo "Certificate to create "+toCreateDomains
|
|
if( 0 == toCreateDomains.size() ){
|
|
echo "All certificate should be refreshed! Nothing to create."
|
|
}else{
|
|
|
|
def lets_encrypt = "docker compose --file lets-encrypt.yml --env-file lets.env "
|
|
|
|
dir("/_programs_/"+repo+"/deploy-this/lets-encrypt"){
|
|
|
|
for( domain in toCreateDomains ){
|
|
|
|
def name = domain[ 1 ]
|
|
|
|
def run = " run --rm certbot certonly"+
|
|
" --webroot -w /var/www/certbot"+
|
|
" --cert-name='"+name+"'"+
|
|
" --non-interactive --agree-tos"+
|
|
" --preferred-challenges http"+
|
|
" --email kusartur@gmail.com" +
|
|
" -d "+name
|
|
|
|
for( int indexSub = 2; indexSub < domain.size(); indexSub ++ ){
|
|
def subDomain = domain[ indexSub ]
|
|
run = run + " -d "+subDomain+ "." + name
|
|
}
|
|
|
|
sh( lets_encrypt+run )
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
stages {
|
|
stage('Make https cert for my domains') {
|
|
steps {
|
|
script{
|
|
def repo_name ="proxy-nginx"
|
|
createCert( domainsToCert, repo_name )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
docker top <name> || docker run --name <name> <image>
|
|
*/
|