For many projects the beginning of "work" in the Pipeline would be the "build"
stage. Typically, this stage of the Pipeline will be where source code is
assembled, compiled, or packaged. The Jenkinsfile is not a replacement for an
existing build tool such as GNU/Make, Maven, and Gradle, but rather can be
viewed as a glue layer to bind the multiple phases of a project’s development
lifecycle (build, test, and deploy) together.
Jenkins has a number of plugins for invoking practically any build tool in
general use, but this example will simply invoke make from a shell step
(sh).  The sh step assumes the system is Unix/Linux-based, for
Windows-based systems the bat could be used instead.
Declarative syntax
Scripted syntax
pipeline { agent any stages { stage('Build') { steps { sh 'make'(1) archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true(2) } } } }
| 1 | The shstep invokes themakecommand and will only continue if a
zero exit code is returned by the command. Any non-zero exit code will fail the
Pipeline. | 
| 2 | archiveArtifactscaptures the files built matching the include pattern
(**/target/*.jar) and saves them to the Jenkins controller for later retrieval. | 
node { stage('Build') { sh 'make'(1) archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true(2) } }
| 1 | The shstep invokes themakecommand and will only continue if a
zero exit code is returned by the command. Any non-zero exit code will fail the
Pipeline. | 
| 2 | archiveArtifactscaptures the files built matching the include pattern
(**/target/*.jar) and saves them to the Jenkins controller for later retrieval. | 
| Archiving artifacts is not a substitute for using external artifact repositories such as Artifactory or Nexus and should be considered only for basic reporting and file archival. |