Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SpringTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Serdar TURKEL
SpringTemplate
Commits
e7b7924d
Commit
e7b7924d
authored
Nov 11, 2022
by
Serdar TURKEL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: change jenkins file
parent
ad499f19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
72 deletions
+9
-72
Jenkinsfile
Jenkinsfile
+9
-72
No files found.
Jenkinsfile
View file @
e7b7924d
pipeline
{
agent
{
label
'master'
}
tools
{
maven
"Maven 3.8.6"
}
environment
{
// This can be nexus3 or nexus2
NEXUS_VERSION
=
"nexus3"
// This can be http or https
NEXUS_PROTOCOL
=
"http"
// Where your Nexus is running
NEXUS_URL
=
"nexus.inity.com.tr:8081"
// Repository where we will upload the artifact
NEXUS_REPOSITORY
=
"inity"
// Jenkins credential id to authenticate to Nexus OSS
NEXUS_CREDENTIAL_ID
=
"nexus-credential"
}
agent
any
stages
{
stage
(
'Build'
)
{
steps
{
sh
'mvn dependency:tree -Dverbose -B -DskipTests clean package
'
echo
'Building..
'
}
}
stage
(
"Nexus"
)
{
stage
(
'Test'
)
{
steps
{
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"
;
// Find built artifact under target folder
filesByGlob
=
findFiles
(
glob:
"target/*.${pom.packaging}"
);
// Print some info from the artifact found
echo
"${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
// Extract the path from the File found
artifactPath
=
filesByGlob
[
0
].
path
;
// Assign to a boolean response verifying If the artifact name exists
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:
[
// Artifact generated such as .jar, .ear and .war files.
[
artifactId:
pom
.
artifactId
,
classifier:
''
,
file:
artifactPath
,
type:
pom
.
packaging
],
// Lets upload the pom.xml file for additional information for Transitive dependencies
[
artifactId:
pom
.
artifactId
,
classifier:
''
,
file:
"pom.xml"
,
type:
"pom"
]
]
);
nexusArtifactUploader
(
nexusVersion:
NEXUS_VERSION
,
protocol:
NEXUS_PROTOCOL
,
nexusUrl:
NEXUS_URL
,
groupId:
pom
.
groupId
,
version:
"latest"
,
repository:
NEXUS_REPOSITORY
,
credentialsId:
NEXUS_CREDENTIAL_ID
,
artifacts:
[
// Artifact generated such as .jar, .ear and .war files.
[
artifactId:
pom
.
artifactId
,
classifier:
''
,
file:
artifactPath
,
type:
pom
.
packaging
],
// Lets upload the pom.xml file for additional information for Transitive dependencies
[
artifactId:
pom
.
artifactId
,
classifier:
''
,
file:
"pom.xml"
,
type:
"pom"
]
]
);
}
else
{
error
"*** File: ${artifactPath}, could not be found"
;
}
}
echo
'Testing..'
}
}
stage
(
'Deploy'
)
{
steps
{
echo
'Deploying....'
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment