awslabs / awslabs/aws-codebuild-jenkins-plugin

Can't download artifacts from S3

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

Description

I have buildspec.yml
```
version: 0.2

phases:
build:
commands:
- #some commands
artifacts:
files: '**/*'
base-directory:
```

and in Jenkinsfile configuration for run CodeBuild
```
stage('Execute CodeBuild') {
steps {
withAWS(region: params.region, role: params.role, roleAccount: params.sdlcAccount) {
awsCodeBuild(
credentialsType: 'keys',
projectName: "${params.codebuildProject}",
region: "${params.region}",
sourceControlType: 'jenkins',
sourceTypeOverride: 'S3',
sourceLocationOverride: "${params.s3Bucket}/tests/${JOB_BASE_NAME}/${BUILD_ID}/source.zip",
buildSpecFile: '.jenkins/bat-api/buildspec.yml',
envVariables: "[{ENV,${params.env}},{REGION,${getRegion()}}]",
artifactTypeOverride: 'S3',
artifactPackagingOverride: 'ZIP',
artifactLocationOverride: "${params.s3Bucket}",
artifactPathOverride: "tests/${JOB_BASE_NAME}/${BUILD_ID}",
artifactNameOverride: 'results.zip',
downloadArtifacts: 'true',
downloadArtifactsRelativePath: ''
)
}
}
}
```

When I execute jenkins job I get error
```
[AWS CodeBuild Plugin] Downloading artifact from location 'arn:aws:s3:::${params.s3Bucket}/tests/${JOB_BASE_NAME}/${BUILD_ID}/results.zip' to path:/home/jenkins/workspace/${JOB_BASE_NAME}/tests/${JOB_BASE_NAME}/${BUILD_ID}/results.zip
[AWS CodeBuild Plugin] Failed to create directory /home/jenkins/workspace/${JOB_BASE_NAME}/tests/${JOB_BASE_NAME}/${BUILD_ID}
```

If I remove ```downloadArtifacts: 'true' ``` and add separate step
```
s3Download(bucket: "${params.s3Bucket}", path: "tests/${JOB_BASE_NAME}/${BUILD_ID}/results.zip", file: 'results.zip')
```
everything work fine

I also tried to execute command before
```
sh "mkdir -p tests/${JOB_BASE_NAME}/${BUILD_ID}"
```

**Expected result**
/home/jenkins/workspace/${JOB_BASE_NAME}/results.zip exists

Contributor guide

Open the contributing guide

Research direction

Start with the Jenkinsfile configuration using downloadArtifacts: 'true' and the plugin's artifact-download entry point; compare its S3 path and workspace-directory handling with the separate s3Download step shown. Reproduce the failure with the provided buildspec.yml and overrides, then verify that the artifact is downloaded to the expected workspace path without requiring literal Jenkins variables in directory creation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.