-
Notifications
You must be signed in to change notification settings - Fork 1
/
pipeline-s3-artifact
35 lines (34 loc) · 1.27 KB
/
pipeline-s3-artifact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
node {
def mvnHome
stage('getscm') { // for display purposes
// Get some code from a GitHub repository
git 'https://github.com/chetanshell/tomcatdeploy.git'
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'maven'
}
stage('Build') {
// Run the maven build
if (isUnix()) {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
} else {
echo 'this is build maven artifact'
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean package/)
}
}
// stage('artifact') {
// archive 'target/*.war'
// }
// stage ('deploy'){
// echo 'deployment started'
// sh "cp /var/lib/jenkins/workspace/${JOB_NAME}/target/*.war /opt/apache-tomcat-8.5.57/webapps/"
// }
stage('artifacts to s3') {
// you need aws credentials
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 's3', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
sh "/usr/local/bin/aws s3 ls"
sh "/usr/local/bin/aws s3 cp /var/lib/jenkins/workspace/${JOB_NAME}/target/*.war s3://newbucketnex/"
}
}
}