Browse Source

Change keygen

Admin User 7 years ago
parent
commit
f4d939342e
1 changed files with 18 additions and 17 deletions
  1. 18 17
      Jenkinsfile_genkey

+ 18 - 17
Jenkinsfile_genkey

@@ -25,7 +25,7 @@ pipeline {
       defaultValue: "test",
       description: "The names for generation keys and certs."
     )
-	string(
+    string(
       name: "mode",
       defaultValue: "client",
       description: "For who generate cert, key and conf-file (clients or admins)"
@@ -83,12 +83,12 @@ pipeline {
                   git clone ${OVPN_GIT_URL}'''
           }
           
-		  if (mode == 'client') {
+          if (mode == 'client') {
             file = "${WORKSPACE}/${OVPN_GIT_DIR}/ip_client.txt"
-		  } 
-		  if (mode == 'admin') {
-		    file = "${WORKSPACE}/${OVPN_GIT_DIR}/ip_admin.txt"
-		  }
+          } 
+          if (mode == 'admin') {
+           file = "${WORKSPACE}/${OVPN_GIT_DIR}/ip_admin.txt"
+          }
           string ip = readFile(file)
           split = ip.tokenize(".")
           if (split[3].toInteger() >= 254) {
@@ -102,12 +102,12 @@ pipeline {
 
               def conf = "${WORKSPACE}/${OVPN_GIT_DIR}/${OVPN_GIT_DIR}/ccd/${key_name}"
               if (mode == 'client') {
-			    writeFile file: conf, text: "ifconfig-push " + newIp + " 255.255.255.0"
-			  }
-			  if (mode == 'admin') {
-			    writeFile file: conf, text: "ifconfig-push " + newIp + " 255.255.0.0"
-			  }
-          }
+                writeFile file: conf, text: "ifconfig-push " + newIp + " 255.255.255.0"
+              }
+              if (mode == 'admin') {
+                writeFile file: conf, text: "ifconfig-push " + newIp + " 255.255.0.0"
+              }
+            }
           withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
             sh '''cd ${OVPN_GIT_DIR}
                   echo "Add new config for ${key_name}" > ../commit.txt
@@ -117,7 +117,7 @@ pipeline {
                   git commit -F ../commit.txt
                   GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
                   git push origin master
-                  ls'''
+               '''
           }
         }
       }
@@ -131,12 +131,13 @@ pipeline {
           echo "Pull new OPENVPN-PKI repo version"
           withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
             sh '''GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
-                  git clone ${PKI_GIT_URL}'''
+                  git clone ${PKI_GIT_URL}
+               '''
           }
           echo "Send certs,key and config-file to client"
           fileZip = "${WORKSPACE}/${PKI_GIT_NAME}/open/easy-rsa/client_keys/sds-${key_name}.zip"
           if ( !fileExists("${fileZip}")) {
-		    currentBuild.result == 'FAILURE'
+            currentBuild.result == 'FAILURE'
             return
           } else {
             withEnv(["zip=${fileZip}"]) {
@@ -148,8 +149,8 @@ pipeline {
                       -u ${USERNAME} \
                       -i ${PASSWORD} \
                       -a ${zip} \
-                    ${client_mail}
-                 '''
+                      ${client_mail}
+                   '''
               }
             }
           }