awslabs / awslabs/aws-codebuild-jenkins-plugin

Artifacts download to workspace on Jenkins master rather than slave

Open
#112 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
156
Forks
130
PR merge metrics
No merged PRs in 30d

Description

When the plugin pulls artifacts from S3, I've noticed that it downloads them to the workspace on the Jenkins master rather than the slave which the job is running on. This then causes archiveArtifacts to fail because it can't find the artifact on the slave. Is there a parameter I can use to tell the plugin to download the artifacts to the slave rather than the master?

**buildspec.yml:**
```
version: 0.2

phases:
install:
runtime-versions:
java: corretto8
run-as: root
artifacts:
files:
- 'application.properties'
```
**Jenkins pipeline:**
```
pipeline {
agent { label 'springboot-linux' }

stages {
stage('Execute CodeBuild') {
steps {
awsCodeBuild(
projectName: 'Springboot',
region: 'eu-west-1',
credentialsId: 'aws-codebuild',
credentialsType: 'jenkins',
sourceControlType: 'project',
sourceVersion: 'springboot_branch',
downloadArtifacts: 'true',
downloadArtifactsRelativePath: ''
)
archiveArtifacts artifacts: 'application.properties'
}
}
}
}
```

**Jenkins build log:**
```
11:06:35 [AWS CodeBuild Plugin] Downloading artifact from location 'arn:aws:s3:::s3_bucket/codebuild/Springboot' to path:/opt/jenkins/workspace/SPRINGBOOT/CodeBuild_Test_Build
[Pipeline] archiveArtifacts
11:06:42 Archiving artifacts
11:06:43 ‘application.properties’ doesn’t match anything
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.AbortException: No artifacts found that match the file pattern "application.properties". Configuration error?
at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:280)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor2170.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:92)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:70)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
```

Location of artifact on Jenkins master:
```
root@0bbda5d3f825:~# ls -l /opt/jenkins/workspace/SPRINGBOOT/CodeBuild_Test_Build/codebuild/Springboot/application.properties
-rw-r--r-- 1 root root 167 Aug 11 11:06 /opt/jenkins/workspace/SPRINGBOOT/CodeBuild_Test_Build/codebuild/Springboot/application.properties
```

Contributor guide

Open the contributing guide

Research direction

Start with the awsCodeBuild pipeline step and its artifact-download path, using the supplied Jenkins pipeline and build log to reproduce the master-versus-slave behavior. Done means artifacts are downloaded into the active slave workspace and archiveArtifacts can find application.properties there.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.