Jenkins (CI/CD Pipeline)
1 min read
ssh -i "Docker-pair.pem" ubuntu@ec2-52-207-224-162.compute-1.amazonaws.com
c9dc8813dcc04e0192907992dcf2f3fc
dir() =
In a Jenkins Pipeline, dir() is a step used to change the working directory for the duration of a block of code. Itβs especially useful in Declarative or Scripted Pipelines when you want to run certain steps inside a specific subdirectory of your workspace.
π Syntax Example (Declarative Pipeline)
`pipeline { agent any
stages {
stage('Build') {
steps {
dir('my-subfolder') {
sh 'mvn clean install'
}
}
}
}
}`
π§ What It Does
- Temporarily switches the working directory to
my-subfolder. - Executes all steps inside that block from that directory.
- After the block ends, Jenkins returns to the original workspace directory.