mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-26 00:45:50 +00:00
dzone way
This commit is contained in:
parent
b84289ece9
commit
946e12d32e
1 changed files with 45 additions and 45 deletions
90
Jenkinsfile
vendored
90
Jenkinsfile
vendored
|
@ -31,52 +31,52 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('checkout') {
|
stage("publish to nexus") {
|
||||||
steps {
|
steps {
|
||||||
checkout scm
|
script {
|
||||||
}
|
// Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps
|
||||||
}
|
pom = readMavenPom file: "pom.xml";
|
||||||
// stage('Publish') {
|
// Find built artifact under target folder
|
||||||
// def pom = readMavenPom file: 'pom.xml'
|
filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
|
||||||
// nexusPublisher nexusInstanceId: 'your-nexus-instance-id', \
|
// Print some info from the artifact found
|
||||||
// nexusRepositoryId: ${env.NEXUS_REPOSITORY}, \
|
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
|
||||||
// packages: [[$class: 'MavenPackage', \
|
// Extract the path from the File found
|
||||||
// mavenAssetList: [[classifier: '', extension: '', filePath: "target/${pom.artifactId}-${pom.version}.${pom.packaging}"], \
|
artifactPath = filesByGlob[0].path;
|
||||||
// [classifier: 'sources', extension: '', filePath: "target/${pom.artifactId}-${pom.version}-sources.${pom.packaging}"]], \
|
// Assign to a boolean response verifying If the artifact name exists
|
||||||
// mavenCoordinate: [artifactId: "${pom.artifactId}", \
|
artifactExists = fileExists artifactPath;
|
||||||
// groupId: "${pom.groupId}", \
|
|
||||||
// packaging: "${pom.packaging}", \
|
if(artifactExists) {
|
||||||
// version: "${pom.version}-${env.BUILD_NUMBER}"]]]
|
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
|
||||||
// }
|
|
||||||
stage('push') {
|
nexusArtifactUploader(
|
||||||
steps {
|
nexusVersion: NEXUS_VERSION,
|
||||||
nexusPublisher nexusInstanceId: 'maven-nexus-repo', nexusRepositoryId: 'maven-releases', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: '.jar', filePath: '/target/']], mavenCoordinate: [artifactId: 'spring-petclinic', groupId: 'org.springframework.samples', packaging: 'pom', version: '2.4.2']]]
|
protocol: NEXUS_PROTOCOL,
|
||||||
// script {
|
nexusUrl: NEXUS_URL,
|
||||||
// pom = readMavenPom file: "pom.xml";
|
groupId: pom.groupId,
|
||||||
// filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
|
version: pom.version,
|
||||||
// echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
|
repository: NEXUS_REPOSITORY,
|
||||||
// artifactPath = filesByGlob[0].path;
|
credentialsId: NEXUS_CREDENTIAL_ID,
|
||||||
// artifactExists = fileExists artifactPath;
|
artifacts: [
|
||||||
// //
|
// Artifact generated such as .jar, .ear and .war files.
|
||||||
// // if(artifactExists) {
|
[artifactId: pom.artifactId,
|
||||||
// // echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
|
classifier: '',
|
||||||
//
|
file: artifactPath,
|
||||||
// nexusArtifactUploader nexusVersion: "${env.NEXUS_VERSION}", protocol: "${env.NEXUS_PROTOCOL}", nexusUrl: "${env.NEXUS_URL}", groupId: pom.groupId, version: pom.version, repository: "${env.NEXUS_REPOSITORY}", credentialsId: "${env.NEXUS_CREDENTIAL_ID}", artifacts: [
|
type: pom.packaging],
|
||||||
// [artifactId: pom.artifactId,
|
|
||||||
// classifier: '',
|
// Lets upload the pom.xml file for additional information for Transitive dependencies
|
||||||
// file: artifactPath,
|
[artifactId: pom.artifactId,
|
||||||
// type: pom.packaging],
|
classifier: '',
|
||||||
// [artifactId: pom.artifactId,
|
file: "pom.xml",
|
||||||
// classifier: '',
|
type: "pom"]
|
||||||
// file: "pom.xml",
|
]
|
||||||
// type: "pom"]
|
);
|
||||||
// ]
|
|
||||||
// ;
|
} else {
|
||||||
}
|
error "*** File: ${artifactPath}, could not be found";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// } else {
|
|
||||||
// error "*** File: ${artifactPath}, could not be found";
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue