Commit e1832957 authored by Josh Steinberg's avatar Josh Steinberg

update jenkinsfile

parent 76019847
...@@ -25,7 +25,6 @@ pipeline { ...@@ -25,7 +25,6 @@ pipeline {
} }
stage('Sonarqube'){ stage('Sonarqube'){
steps{ steps{
echo "running Sonar ******************************************************"
withSonarQubeEnv('sonar'){ withSonarQubeEnv('sonar'){
sh 'mvn package sonar:sonar' sh 'mvn package sonar:sonar'
} }
...@@ -40,57 +39,71 @@ pipeline { ...@@ -40,57 +39,71 @@ pipeline {
} }
stage("Pulbish to Nexus"){ stage("Pulbish to Nexus"){
steps{ steps{
script{ nexusArtifactUploader artifacts: [
pom = readMavenPom file: "pom.xml"; [artifactId: 'spring-boot-complete',
filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); classifier: '',
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" file: 'target/spring-boot-complete-0.0.1-SNAPSHOT.jar',
artifactPath = filesByGlob[0].path; type: 'jar']
artifactExists = fileExists artifactPath; ],
if(artifactExists) { credentialsId: NEXUS_CREDENTIAL_ID,
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; groupId: 'com.example',
nexusArtifactUploader( nexusUrl: NEXUS_URL,
nexusVersion: NEXUS_VERSION, nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL, protocol: 'http',
nexusUrl: NEXUS_URL, repository: NEXUS_REPOSITORY,
groupId: pom.groupId, version: '0.0.1-SNAPSHOT'
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";
}
}
} }
} }
// 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"){ // stage("Pull from Nexus"){
steps{ // steps{
script{ // script{
pom = readMavenPom file: "pom.xml"; // pom = readMavenPom file: "pom.xml";
GROUP_ID=pom.groupId // GROUP_ID=pom.groupId
ARTIFACT_ID=pom.artifactId // ARTIFACT_ID=pom.artifactId
LOCAL_FILE="spring-boot-complete-0.0.1-SNAPSHOT.jar" // 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}" // 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()" -` // 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}" // ARTIFACT_DOWNLOAD_URL="${NEXUS_URL}/repositories/${NEXUS_REPOSITORY}/content${REPOSITORY_LOCAL_PATH}"
`curl -o "${LOCAL_FILE}" "${ARTIFACT_DOWNLOAD_URL}"` // curl -o "${LOCAL_FILE}" "${ARTIFACT_DOWNLOAD_URL}"
echo "${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