> For the complete documentation index, see [llms.txt](https://tkssharma-devops.gitbook.io/devops-training/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tkssharma-devops.gitbook.io/devops-training/devops-01-continuous-integration/continuous-integration-and-continuous-delivery/ci-cd-using-jenkins-ci/jenkins-ci-cd-with-aws/create-a-build-pipleine/pipeline-examples.md).

# Pipeline Examples

{% embed url="<https://github.com/jenkinsci/pipeline-examples/tree/master/declarative-examples/simple-examples>" %}

```
pipeline {
  agent {
    dockerfile {
      /*
       * This assumes that a "Dockerfile" is in the current workspace
       * A new container will be build with the args below and the pipeline will run inside that container.
       */
      args "-v /tmp:/tmp -p 8000:8000"
    }
  }
  stages {
    stage("foo") {
      steps {
        sh 'cat /hi-there'
        sh 'echo "The answer is 42"'
      }
    }
  }
}
```

```

pipeline {
  agent any

  environment {
    // FOO will be available in entire pipeline
    FOO = "PIPELINE"
  }

  stages {
    stage("local") {
      environment {
        // BAR will only be available in this stage
        BAR = "STAGE"
      }
      steps {
        sh 'echo "FOO is $FOO and BAR is $BAR"'
      }
    }
    stage("global") {
      steps {
        sh 'echo "FOO is $FOO and BAR is $BAR"'
      }
    }
  }
}
```
