浏览代码

try this instead part 3

nossr50 1 天之前
父节点
当前提交
2f452afdc7
共有 1 个文件被更改,包括 21 次插入22 次删除
  1. 21 22
      Jenkinsfile

+ 21 - 22
Jenkinsfile

@@ -25,28 +25,27 @@ pipeline {
 			}
 			}
 		}
 		}
 
 
-		stage('Deploy to Nexus') {
-			steps {
-				withCredentials([usernamePassword(
-					credentialsId: 'nexus-deployer',
-					usernameVariable: 'NEXUS_USER',
-					passwordVariable: 'NEXUS_PASS'
-				)]) {
-					writeFile file: 'settings.xml', text: """
-                    <settings>
-                      <servers>
-                        <server>
-                          <id>neetgames</id>
-                          <username>${env.NEXUS_USER}</username>
-                          <password>${env.NEXUS_PASS}</password>
-                        </server>
-                      </servers>
-                    </settings>
-                    """
-					sh 'mvn -s settings.xml -V -B deploy'
-				}
-			}
-		}
+        stage('Deploy to Nexus') {
+            steps {
+                withCredentials([usernamePassword(
+                    credentialsId: 'nexus-deployer',
+                    usernameVariable: 'NEXUS_USER',
+                    passwordVariable: 'NEXUS_PASS'
+                )]) {
+                    configFileProvider([configFile(fileId: 'maven-settings-nexus', variable: 'MAVEN_SETTINGS_TEMPLATE')]) {
+                        sh '''
+                          # Expand env vars into a real settings file
+                          envsubst < "$MAVEN_SETTINGS_TEMPLATE" > settings.xml
+
+                          mvn -s settings.xml -V -B deploy
+
+                          rm -f settings.xml
+                        '''
+                    }
+                }
+            }
+        }
+
 	}
 	}
 
 
 	post {
 	post {