Certified Jenkins Engineer

Extending Jenkins and Administration

Demo Installing Plugins

In this step-by-step tutorial, we’ll install and configure two essential Jenkins plugins—Copy Artifact and Yet Another Build Visualizer—to enable artifact sharing between freestyle jobs and to visualize your build pipelines.


Plugins Overview

Plugin NamePurposeDocumentation
Copy ArtifactShare build artifacts between jobsplugins.jenkins.io/copyartifact
Yet Another Build VisualizerDisplay upstream/downstream job relationshipsGitHub Repository

1. Installing the Copy Artifact Plugin

We already have a job called ascii-build-job that fetches advice from an external API:

The image shows a Jenkins dashboard for a project named "ascii-build-job," displaying build history and permalinks for recent builds. The interface includes options for managing the project, such as configuring and deleting it.

To allow another job to consume advice.json, install Copy Artifact:

  1. Navigate to Manage JenkinsManage Plugins.

  2. Click the Installed tab to check which plugins are already present:

    The image shows the "Installed plugins" section of a Jenkins dashboard, listing various plugins with options to enable or disable them.

  3. Go to the Available tab, search for “copy artifact”, select it, then click Install without restart:

    The image shows the Jenkins plugin management interface, displaying a list of available plugins with options to install them. The interface includes details like plugin names, descriptions, and release dates.

    The image shows a Jenkins dashboard displaying a list of available plugins, with options to install them. The interface includes a search bar and details about each plugin, such as name, description, and release date.

  4. Wait until the status indicator reads Success:

    The image shows a Jenkins plugin management interface with a list of plugins, each marked with a "Success" status, indicating successful installation or update.

  5. Review the plugin’s usage patterns, including declarative pipeline snippets and CLI installation:

    The image shows a webpage for the "Copy Artifact" plugin on the Jenkins website, detailing its features, version information, and installation statistics. It includes a section on how to configure the plugin to copy artifacts from another project.

    // Declarative pipeline example
    pipeline {
      agent any
      options {
        copyArtifactPermission('job1,job2')
      }
      stages {
        // ...
      }
    }
    
    // Freestyle project permission
    properties {
      copyArtifactPermission('ascii-test-job')
    }
    

    Or install via CLI:

    jenkins-plugin-cli --plugins copyartifact:1.46.1
    

    The image shows a Jenkins plugin page for "Copy Artifact," displaying a health score of 83% and various details about adoption, deprecation, documentation, and security. It also includes links and information about the plugin's version and maintainers.

Warning

If you install via CLI, ensure Jenkins has been restarted or the plugin has been dynamically loaded. Always verify compatibility with your Jenkins version.


2. Configure the Build Job (ascii-build-job)

Edit ascii-build-job to fetch and archive advice:

  1. Execute Shell – Fetch advice and output to advice.json:

    curl -s https://api.adviceslip.com/advice > advice.json
    cat advice.json
    
  2. Allow Copy Artifact – Under ConfigurePermission to Copy Artifact, add ascii-test-job:

    The image shows a Jenkins configuration screen for a job named "ascii-build-job," with options for build settings such as "Permission to Copy Artifact" and other build parameters.

  3. Archive Artifacts – Post-build action to archive advice.json:

    The image shows a Jenkins configuration screen for a job named "ascii-build-job," focusing on post-build actions like archiving artifacts and building other projects.

Save and run ascii-build-job. You should see advice.json archived under Build Artifacts.


3. Configure the Test Job (ascii-test-job)

Now set up ascii-test-job to pull that artifact and validate its content:

  1. Copy Artifacts from Another Project (drag this step to the top):

    • Project Name: ascii-build-job
    • Which Build: Latest successful
    • Artifacts to Copy: advice.json

    The image shows a Jenkins configuration screen for a project named "ascii-test-job," focusing on the "Build Steps" section where options for copying artifacts from another project are being selected.

  2. Execute Shell – Validate the advice message length:

    # Ensure advice.json is present
    ls advice.json
    
    # Extract advice text
    cat advice.json | jq -r .slip.advice > advice.message
    
    # Validate word count > 5
    if [ $(wc -w < advice.message) -gt 5 ]; then
      echo "Advice: $(cat advice.message) has more than 5 words"
    else
      echo "Advice: not enough words"
    fi
    
  3. Archive Artifacts – Only archive advice.message on success:

    The image shows a Jenkins configuration screen for post-build actions, specifically for archiving artifacts with various options and settings.

Save and run ascii-test-job. Verify both artifacts in the workspace:

The image shows a Jenkins workspace interface for a job named "ascii-test-job" on a built-in node, displaying two files: "advice.json" and "advice.message," along with their details. The build history is visible on the left side.

Console output should confirm the artifact copy and message extraction:

Copied 1 artifact from "ascii-build-job" build #3
Advice: What could you increase? What could you reduce? has more than 5 words
Finished: SUCCESS

4. Configure the Deploy Job (ascii-deploy-job)

Create ascii-deploy-job to consume advice.message and display it with cowsay:

  1. Copy Artifacts from ascii-test-job (Latest stable), artifacts: advice.message.
  2. Execute Shell:
    sudo apt-get update
    sudo apt-get install -y cowsay
    export PATH=$PATH:/usr/games:/usr/local/games
    
    cat advice.message | cowsay -f $(ls /usr/share/cowsay/cows | shuf -n 1)
    
  3. Build Trigger – Under Build Triggers, select Build after other projects are builtascii-test-job (stable only).

Save and kick off the chain by building ascii-build-job. You’ll observe:

  • ascii-build-job runs first and archives advice.json.
  • ascii-test-job copies that artifact, extracts advice.message, and archives it.
  • ascii-deploy-job triggers automatically and displays the advice in a random cow figure.

Console logs of ascii-deploy-job:

The image shows a Jenkins build status page for a job named "ascii-deploy-job," detailing the build process, timing, and upstream projects involved. It includes information about the build duration, user initiation, and related jobs.


5. Visualizing the Build Flow

To graphically map upstream/downstream relationships, install Yet Another Build Visualizer:

  1. Download the latest HPI from the [releases page]:

    The image shows a webpage for the "Yet Another Build Visualizer" Jenkins plugin, featuring build flow diagrams and plugin details such as version, features, and links.

  2. In Manage JenkinsManage PluginsAdvanced, upload and deploy the HPI:

    The image shows a Jenkins plugin management page with a list of plugins and their installation statuses, where most are marked as "Success" and a few as "Pending." The sidebar includes options like "Updates," "Available plugins," and "Download progress."

  3. Open ascii-build-job to view the build flow diagram:

    The image shows a Jenkins dashboard for a project named "ascii-build-job," displaying build flow, downstream projects, and build history details.

Use the interactive toggles to inspect build numbers, statuses, and full job names. This visualization helps you quickly understand and debug complex job chains.


That’s it! You’ve successfully installed and configured the Copy Artifact and Yet Another Build Visualizer plugins to streamline artifact sharing and gain clear insights into your Jenkins build pipelines.

Watch Video

Watch video content

Previous
Jenkins Plugins