0
0
Jenkinsdevops~5 mins

Copying artifacts between jobs in Jenkins - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Copying artifacts between jobs
O(n)
Understanding Time Complexity

When copying artifacts between Jenkins jobs, it's important to know how the time to copy grows as the number of artifacts increases.

We want to understand how the copying process scales with more files.

Scenario Under Consideration

Analyze the time complexity of the following Jenkins pipeline snippet.


    pipeline {
      agent any
      stages {
        stage('Copy Artifacts') {
          steps {
            copyArtifacts(projectName: 'upstream-job', selector: lastSuccessful())
          }
        }
      }
    }
    

This code copies all artifacts from the last successful build of another job.

Identify Repeating Operations

Look for repeated actions that affect time.

  • Primary operation: Copying each artifact file one by one.
  • How many times: Once for each artifact file in the source job.
How Execution Grows With Input

As the number of artifact files grows, the copying time grows too.

Input Size (n)Approx. Operations
1010 file copy operations
100100 file copy operations
10001000 file copy operations

Pattern observation: The time grows directly with the number of files copied.

Final Time Complexity

Time Complexity: O(n)

This means the copying time increases linearly as the number of artifact files increases.

Common Mistake

[X] Wrong: "Copying artifacts happens instantly no matter how many files there are."

[OK] Correct: Each file must be copied individually, so more files mean more time.

Interview Connect

Understanding how copying artifacts scales helps you design efficient pipelines and manage build times well.

Self-Check

What if we compressed all artifacts into one file before copying? How would the time complexity change?