Using encrypted password in Maven POM.xml -
background: need automate deployment of project(jar files). based on user input, jar file deployed on different server based on selected environment.
example: using bat/cmd file ask user select environment.
set /p environ=please enter execution environment(enter 1 dev, 2 qa, 3 stage, 4 prod) :
based on user input passing credentials like.
mvn install -dftp.username=user -dftp.password=password -dftp.server=servername
the input user, password, servername changes based on selected environment.
requirement: passing encrypted password in pom.xml needs decrypted maven (may using plugin) .
i tried maven-encryption no success. use feature need know how can get/read decrypted password in pom
plugin using deploying.
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <executions> <execution> <id>ftp</id> <phase>install</phase> <configuration> <tasks> <!-- if files needs deployed remote ftp server, once can use below scp tag mvn install -dftp.password=password --> <scp todir="${ftp.username}@${ftp.server}:${ftp.remotefolder}" sftp="${ftp.sftp}" port="${ftp.port}" trust="true" password="${ftp.password}" failonerror="false" verbose="true" passphrase=""> <fileset dir="${project.build.directory}"> <include name="*.jar" /> </fileset> </scp> <!-- if files needs deployed remote ftp server, once can use above scp tag --> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupid>org.apache.ant</groupid> <artifactid>ant-jsch</artifactid> <version>1.9.4</version> </dependency> </dependencies> </plugin>
Comments
Post a Comment