Uploaded image for project: 'Jenkins Website'
  1. Jenkins Website
  2. WEBSITE-419

Create a new 'Using Jenkins to build a multibranch Pipeline project (with selective stages)' tutorial in the Jenkins User Documentation

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Tutorial outline/plan:

      Note: I'd recommend reviewing the WEBSITE-412 tutorial first before proceeding because it's like a prequel to this one.

      Readers effectively start off with a Jenkinsfile Pipeline that has both a "Build" and "Test" stage in it. This is effectively the same as the Jenkinsfile that readers create in WEBSITE-412 tutorial (but only up to and including the "Test" stage). From that point on, things change dramatically.

      The tutorial process (at a high-level) will be:

      1. The reader forks the "building-a-multibranch-pipeline-project" GitHub project and clones it locally (fairly standard so far).
        This project is effectively the same as the "simple-node-js-react-npm-app" used in WEBSITE-412, but with different 'deliver-for-development.sh' and 'deploy-for-production.sh' scripts which are run selectively depending on the branch that Jenkins executes.
      2. Reader creates (locally) 2 branches from the single "master" branch in this repo - "production" and "development".
        Note: I decided not to use the "master" branch for "production" purposes because I don't think this is that common/recommended in practice. For example, a "production" branch might be in use for some time while unstable development continues along the "master" branch. (Please feel free to correct me if I'm wrong and we can alter this step to suit.)
      3. Reader configures their multibranch Pipeline project in the Blue Ocean UI using the Git option. The presence of a 'bare' Jenkinsfile in the original "master" branch is to populate the Blue Ocean UI with each branch in the repo (making them accessible without having to leave the Blue Ocean UI).
      4. Reader updates the existing 'bare' Jenkinsfile with the initial "Build" and "Test" stages for the project in the "master" branch.
      5. Reader switches to Blue Ocean in Jenkins and builds the "master" branch to see the end result - i.e. the "Build" and "Test" stages are executed.
      6. Reader adds the "Deliver for development" and "Deploy for production" stages to their Jenkinsfile (in the "master" branch), runs a build in Jenkins again and sees that these two stages are bypassed - i.e. none of these newly added stages actually execute (because both these stages have "when" conditions that aren't yet satisfied).
      7. Reader switches to Blue Ocean in Jenkins again and builds the "develop" and "production" branches to see the end result - i.e. the "Deliver for development" (because its "when { branch 'development' }" condition is satisfied) and "Deploy for production" (because its "when { branch 'production' }" condition is satisfied) stages are selectively executed.
        • The "Deliver for development" stage is effectively the npm start (and associated) commands in the deliver.sh script (of "simple-node-js-react-npm-app" for WEBSITE-412).
        • This "Deploy for production" stage is effectively the npm install -g serve followed by serve -c 0 -s build in the deploy-for-production.sh script of "building-a-multibranch-pipeline-project".

      As an optional 'Follow up' section:

      1. Reader checks out the "development" branch, makes some changes to the src/App.js file and commits it to the "development" branch.
      2. Reader switches to Blue Ocean in Jenkins again and builds the "development" branch to see the end result of the "Deliver for development" build.
      3. Reader pulls changes from their "development" branch to their "production" branch (via "master") and back in Blue Ocean again, builds the "production" branch to see the end result of the "Deploy for production" build.
      4. Mention how reader can submit a PR to master (as a sum up line).

        Attachments

          Activity

          ggaskell Giles Gaskell created issue -
          ggaskell Giles Gaskell made changes -
          Field Original Value New Value
          Summary Using Jenkins to build multibranch projects using selective stages. Using Jenkins to build a multibranch project using selective stages
          ggaskell Giles Gaskell made changes -
          Summary Using Jenkins to build a multibranch project using selective stages Create a new 'Using Jenkins to build a multibranch project using selective stages' tutorial in the Jenkins User Documentation
          ggaskell Giles Gaskell made changes -
          Summary Create a new 'Using Jenkins to build a multibranch project using selective stages' tutorial in the Jenkins User Documentation Create a new 'Using Jenkins to build a multibranch project with selective stages' tutorial in the Jenkins User Documentation
          ggaskell Giles Gaskell made changes -
          Assignee Giles Gaskell [ ggaskell ]
          ggaskell Giles Gaskell made changes -
          Remote Link This issue links to "This issue supersedes pull request 635 (Web Link)" [ 17896 ]
          ggaskell Giles Gaskell made changes -
          Remote Link This issue links to "This issue supersedes pull request 635 (Web Link)" [ 17896 ]
          ggaskell Giles Gaskell made changes -
          Remote Link This issue links to "GitHub pull request 635 is superseded by this task (Web Link)" [ 17897 ]
          ggaskell Giles Gaskell made changes -
          Summary Create a new 'Using Jenkins to build a multibranch project with selective stages' tutorial in the Jenkins User Documentation Create a new 'Using Jenkins to build a multibranch Pipeline project with selective stages' tutorial in the Jenkins User Documentation
          ggaskell Giles Gaskell made changes -
          Summary Create a new 'Using Jenkins to build a multibranch Pipeline project with selective stages' tutorial in the Jenkins User Documentation Create a new 'Using Jenkins to build a multibranch Pipeline project (with selective stages)' tutorial in the Jenkins User Documentation
          ggaskell Giles Gaskell made changes -
          Description *Tutorial outline/plan:*

          *Note:* I'd recommend reviewing the [WEBSITE-412 tutorial first|https://github.com/jenkins-infra/jenkins.io/pull/1184] before proceeding because it's like a prequel to this one.

          Readers effectively start off with a Jenkinsfile Pipeline that has both a "Build" and "Test" stage in it. This is effectively the same as the Jenkinsfile that readers create in WEBSITE-412 tutorial (but only up to and including the "Test" stage). From that point on, things change dramatically.

          _The tutorial process (at a high-level) will be:_

          # The reader forks the "building-a-multibranch-pipeline-project" GitHub project and clones it locally (fairly standard so far).
          \\
          This project is effectively the same as the "simple-node-js-react-npm-app" used in WEBSITE-412, but with different 'deliver-for-development.sh' and 'deploy-for-production.sh' scripts which are run selectively depending on the branch that Jenkins executes.
          # Reader creates (locally) 2 branches from the single "master" branch in this repo - "production" and "development".
          \\
          *Note:* I decided not to use the "master" branch for "production" purposes because I don't think this is that common/recommended in practice. For example, a "production" branch might be in use for some time while unstable development continues along the "master" branch. (Please feel free to correct me if I'm wrong and we can alter this step to suit.)
          # Reader configures their multibranch Pipeline project in the Blue Ocean UI using the Git option. The presence of a 'bare' Jenkinsfile in the original "master" branch is to populate the Blue Ocean UI with each branch in the repo (making them accessible without having to leave the Blue Ocean UI).
          # Reader updates the existing 'bare' Jenkinsfile with the initial "Build" and "Test" stages for the project in the "master" branch.
          # Reader switches to Blue Ocean in Jenkins and builds the "master" branch to see the end result - i.e. the "Build" and "Test" stages are executed.
          # Reader adds the "Deliver for development" and "Deploy for production" stages to their Jenkinsfile (in the "master" branch), runs a build in Jenkins again and sees that these two stages are bypassed - i.e. none of these newly added stages actually execute (because both these stages have "when" conditions that aren't yet satisfied).
          # Reader switches to Blue Ocean in Jenkins again and builds the "develop" and "production" branches to see the end result - i.e. the "Deliver for development" (because its "when \{ branch 'development' \}" condition is satisfied) and "Deploy for production" (because its "when \{ branch 'production' \}" condition is satisfied) stages are selectively executed.
          #* The "Deliver for development" stage is effectively the {{npm start}} (and associated) commands in the {{deliver.sh}} script (of "simple-node-js-react-npm-app" for WEBSITE-412).
          #* This "Deploy for production" stage is effectively the {{npm install -g serve}} followed by {{serve -c 0 -s build}} in the {{deploy-for-production.sh}} script of "building-a-multibranch-pipeline-project".

          As an optional 'Follow up' section:

          # Reader checks out the "development" branch, makes some changes to the {{src/App.js}} file and commits it to the "development" branch.
          # Reader switches to Blue Ocean in Jenkins again and builds the "development" branch to see the end result of the "Deliver for development" build.
          # Reader pulls changes from their "development" branch to their "production" branch and back in Blue Ocean again, builds the "production" branch to see the end result of the "Deploy for production" build.
          # Mention how reader can submit a PR to master (as a sum up line).
          ggaskell Giles Gaskell made changes -
          Status To Do [ 10003 ] In Progress [ 3 ]
          ggaskell Giles Gaskell made changes -
          Remote Link This issue links to "GitHub pull request 1237 (Web Link)" [ 18115 ]
          ggaskell Giles Gaskell made changes -
          Description *Tutorial outline/plan:*

          *Note:* I'd recommend reviewing the [WEBSITE-412 tutorial first|https://github.com/jenkins-infra/jenkins.io/pull/1184] before proceeding because it's like a prequel to this one.

          Readers effectively start off with a Jenkinsfile Pipeline that has both a "Build" and "Test" stage in it. This is effectively the same as the Jenkinsfile that readers create in WEBSITE-412 tutorial (but only up to and including the "Test" stage). From that point on, things change dramatically.

          _The tutorial process (at a high-level) will be:_

          # The reader forks the "building-a-multibranch-pipeline-project" GitHub project and clones it locally (fairly standard so far).
          \\
          This project is effectively the same as the "simple-node-js-react-npm-app" used in WEBSITE-412, but with different 'deliver-for-development.sh' and 'deploy-for-production.sh' scripts which are run selectively depending on the branch that Jenkins executes.
          # Reader creates (locally) 2 branches from the single "master" branch in this repo - "production" and "development".
          \\
          *Note:* I decided not to use the "master" branch for "production" purposes because I don't think this is that common/recommended in practice. For example, a "production" branch might be in use for some time while unstable development continues along the "master" branch. (Please feel free to correct me if I'm wrong and we can alter this step to suit.)
          # Reader configures their multibranch Pipeline project in the Blue Ocean UI using the Git option. The presence of a 'bare' Jenkinsfile in the original "master" branch is to populate the Blue Ocean UI with each branch in the repo (making them accessible without having to leave the Blue Ocean UI).
          # Reader updates the existing 'bare' Jenkinsfile with the initial "Build" and "Test" stages for the project in the "master" branch.
          # Reader switches to Blue Ocean in Jenkins and builds the "master" branch to see the end result - i.e. the "Build" and "Test" stages are executed.
          # Reader adds the "Deliver for development" and "Deploy for production" stages to their Jenkinsfile (in the "master" branch), runs a build in Jenkins again and sees that these two stages are bypassed - i.e. none of these newly added stages actually execute (because both these stages have "when" conditions that aren't yet satisfied).
          # Reader switches to Blue Ocean in Jenkins again and builds the "develop" and "production" branches to see the end result - i.e. the "Deliver for development" (because its "when \{ branch 'development' \}" condition is satisfied) and "Deploy for production" (because its "when \{ branch 'production' \}" condition is satisfied) stages are selectively executed.
          #* The "Deliver for development" stage is effectively the {{npm start}} (and associated) commands in the {{deliver.sh}} script (of "simple-node-js-react-npm-app" for WEBSITE-412).
          #* This "Deploy for production" stage is effectively the {{npm install -g serve}} followed by {{serve -c 0 -s build}} in the {{deploy-for-production.sh}} script of "building-a-multibranch-pipeline-project".

          As an optional 'Follow up' section:

          # Reader checks out the "development" branch, makes some changes to the {{src/App.js}} file and commits it to the "development" branch.
          # Reader switches to Blue Ocean in Jenkins again and builds the "development" branch to see the end result of the "Deliver for development" build.
          # Reader pulls changes from their "development" branch to their "production" branch and back in Blue Ocean again, builds the "production" branch to see the end result of the "Deploy for production" build.
          # Mention how reader can submit a PR to master (as a sum up line).
          *Tutorial outline/plan:*

          *Note:* I'd recommend reviewing the [WEBSITE-412 tutorial first|https://github.com/jenkins-infra/jenkins.io/pull/1184] before proceeding because it's like a prequel to this one.

          Readers effectively start off with a Jenkinsfile Pipeline that has both a "Build" and "Test" stage in it. This is effectively the same as the Jenkinsfile that readers create in WEBSITE-412 tutorial (but only up to and including the "Test" stage). From that point on, things change dramatically.

          _The tutorial process (at a high-level) will be:_

          # The reader forks the "building-a-multibranch-pipeline-project" GitHub project and clones it locally (fairly standard so far).
          \\
          This project is effectively the same as the "simple-node-js-react-npm-app" used in WEBSITE-412, but with different 'deliver-for-development.sh' and 'deploy-for-production.sh' scripts which are run selectively depending on the branch that Jenkins executes.
          # Reader creates (locally) 2 branches from the single "master" branch in this repo - "production" and "development".
          \\
          *Note:* I decided not to use the "master" branch for "production" purposes because I don't think this is that common/recommended in practice. For example, a "production" branch might be in use for some time while unstable development continues along the "master" branch. (Please feel free to correct me if I'm wrong and we can alter this step to suit.)
          # Reader configures their multibranch Pipeline project in the Blue Ocean UI using the Git option. The presence of a 'bare' Jenkinsfile in the original "master" branch is to populate the Blue Ocean UI with each branch in the repo (making them accessible without having to leave the Blue Ocean UI).
          # Reader updates the existing 'bare' Jenkinsfile with the initial "Build" and "Test" stages for the project in the "master" branch.
          # Reader switches to Blue Ocean in Jenkins and builds the "master" branch to see the end result - i.e. the "Build" and "Test" stages are executed.
          # Reader adds the "Deliver for development" and "Deploy for production" stages to their Jenkinsfile (in the "master" branch), runs a build in Jenkins again and sees that these two stages are bypassed - i.e. none of these newly added stages actually execute (because both these stages have "when" conditions that aren't yet satisfied).
          # Reader switches to Blue Ocean in Jenkins again and builds the "develop" and "production" branches to see the end result - i.e. the "Deliver for development" (because its "when \{ branch 'development' \}" condition is satisfied) and "Deploy for production" (because its "when \{ branch 'production' \}" condition is satisfied) stages are selectively executed.
          #* The "Deliver for development" stage is effectively the {{npm start}} (and associated) commands in the {{deliver.sh}} script (of "simple-node-js-react-npm-app" for WEBSITE-412).
          #* This "Deploy for production" stage is effectively the {{npm install -g serve}} followed by {{serve -c 0 -s build}} in the {{deploy-for-production.sh}} script of "building-a-multibranch-pipeline-project".

          As an optional 'Follow up' section:

          # Reader checks out the "development" branch, makes some changes to the {{src/App.js}} file and commits it to the "development" branch.
          # Reader switches to Blue Ocean in Jenkins again and builds the "development" branch to see the end result of the "Deliver for development" build.
          # Reader pulls changes from their "development" branch to their "production" branch (via "master") and back in Blue Ocean again, builds the "production" branch to see the end result of the "Deploy for production" build.
          # Mention how reader can submit a PR to master (as a sum up line).
          ggaskell Giles Gaskell made changes -
          Status In Progress [ 3 ] In Review [ 10005 ]
          ggaskell Giles Gaskell made changes -
          Resolution Fixed [ 1 ]
          Status In Review [ 10005 ] Done [ 10004 ]

            People

            Assignee:
            ggaskell Giles Gaskell
            Reporter:
            ggaskell Giles Gaskell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: