Using a Jenkinsfile | jenkins pipeline always
AsdiscussedintheDefiningaPipelineinSCM[1],aJenkinsfileisatextfilethatcontainsthedefinitionofaJenkinsPipelineandischeckedintosourcecontrol.ConsiderthefollowingPipelinewhichimplementsabasicthree-stagecontinuousdeliverypipeline.Jenkinsfile(DeclarativePipeline)pipeline{agentanystages{stage(Build){steps{echoBuilding..}}stage(Test){steps{echoTesting..}}stage(Deploy){steps{echoDeploying....}}}}Jenkinsfile(ScriptedPipeline)node{stage(Build){echoBuilding....}stage(Test){echoTesting....}stage(Deploy){...
As discussed in the Defining a Pipeline in SCM[1], a Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline and is checked into source control. Consider the following Pipeline which implements a basic three-stage continuous delivery pipeline.
Jenkinsfile (Declarative Pipeline)
pipeline { agent any stages { stage(Build) { steps { echo Building.. } } stage(Test) { steps { echo Testing.. } } stage(Deploy) { steps { echo Deploying.... } } } }Jenkinsfile (Scripted Pipeline)
node { stage(Build) { echo Building.... } stage(Test) { echo Testing.... } stage(Deploy) { echo Deploying.... } }Not all Pipelines will have these same three stages, but it is a good starting point to define them...