Commit e1832957 authored by Josh Steinberg's avatar Josh Steinberg

update jenkinsfile

parent 76019847
......@@ -25,7 +25,6 @@ pipeline {
}
stage('Sonarqube'){
steps{
echo "running Sonar ******************************************************"
withSonarQubeEnv('sonar'){
sh 'mvn package sonar:sonar'
}
......@@ -40,57 +39,71 @@ pipeline {
}
stage("Pulbish to Nexus"){
steps{
script{
pom = readMavenPom file: "pom.xml";
filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
artifactPath = filesByGlob[0].path;
artifactExists = fileExists artifactPath;
if(artifactExists) {
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusArtifactUploader artifacts: [
[artifactId: 'spring-boot-complete',
classifier: '',
file: 'target/spring-boot-complete-0.0.1-SNAPSHOT.jar',
type: 'jar']
],
credentialsId: NEXUS_CREDENTIAL_ID,
groupId: 'com.example',
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
version: pom.version,
nexusVersion: NEXUS_VERSION,
protocol: 'http',
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
[artifactId: pom.artifactId,
classifier: '',
file: artifactPath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: '',
file: "pom.xml",
type: "pom"]
]
);
} else {
error "*** File: ${artifactPath}, could not be found";
}
}
}
}
version: '0.0.1-SNAPSHOT'
}
}
// script{
// pom = readMavenPom file: "pom.xml";
// filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
// echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
// artifactPath = filesByGlob[0].path;
// artifactExists = fileExists artifactPath;
// if(artifactExists) {
// echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
// nexusArtifactUploader(
// nexusVersion: NEXUS_VERSION,
// protocol: NEXUS_PROTOCOL,
// nexusUrl: NEXUS_URL,
// groupId: pom.groupId,
// version: pom.version,
// repository: NEXUS_REPOSITORY,
// credentialsId: NEXUS_CREDENTIAL_ID,
// artifacts: [
// [artifactId: pom.artifactId,
// classifier: '',
// file: artifactPath,
// type: pom.packaging],
// [artifactId: pom.artifactId,
// classifier: '',
// file: "pom.xml",
// type: "pom"]
// ]
// );
// } else {
// error "*** File: ${artifactPath}, could not be found";
// }
// }
// }
stage("Pull from Nexus"){
steps{
script{
pom = readMavenPom file: "pom.xml";
GROUP_ID=pom.groupId
ARTIFACT_ID=pom.artifactId
LOCAL_FILE="spring-boot-complete-0.0.1-SNAPSHOT.jar"
// stage("Pull from Nexus"){
// steps{
// script{
// pom = readMavenPom file: "pom.xml";
// GROUP_ID=pom.groupId
// ARTIFACT_ID=pom.artifactId
// LOCAL_FILE="spring-boot-complete-0.0.1-SNAPSHOT.jar"
NEXUS_RESOLVE_URL="${NEXUS_URL}artifact/maven/resolve?g=${GROUP_ID}a=${ARTIFACT_ID}&r=${NEXUS_REPOSITORY}&v=${NEXUS_VERSION}"
REPOSITORY_LOCAL_PATH= `curl -s "${NEXUS_RESOLVE_URL}" | xmllint --xpath "//artifact-resolution/data/repositoryPath/text()" -`
ARTIFACT_DOWNLOAD_URL="${NEXUS_URL}/repositories/${NEXUS_REPOSITORY}/content${REPOSITORY_LOCAL_PATH}"
`curl -o "${LOCAL_FILE}" "${ARTIFACT_DOWNLOAD_URL}"`
echo "${ARTIFACT_DOWNLOAD_URL}"
}
}
}
// NEXUS_RESOLVE_URL="${NEXUS_URL}artifact/maven/resolve?g=${GROUP_ID}a=${ARTIFACT_ID}&r=${NEXUS_REPOSITORY}&v=${NEXUS_VERSION}"
// REPOSITORY_LOCAL_PATH= curl -s "${NEXUS_RESOLVE_URL}" | xmllint --xpath "//artifact-resolution/data/repositoryPath/text()" -
// ARTIFACT_DOWNLOAD_URL="${NEXUS_URL}/repositories/${NEXUS_REPOSITORY}/content${REPOSITORY_LOCAL_PATH}"
// curl -o "${LOCAL_FILE}" "${ARTIFACT_DOWNLOAD_URL}"
// echo "${ARTIFACT_DOWNLOAD_URL}"
// }
// }
// }
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment