aws-codebuild-jenkins-plugin icon indicating copy to clipboard operation
aws-codebuild-jenkins-plugin copied to clipboard

Can't download artifacts from S3

Open emaks opened this issue 4 years ago • 1 comments

I have buildspec.yml

version: 0.2

phases:
  build:
    commands:
      - #some commands
artifacts:
  files: '**/*'
  base-directory: <project-folder>

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

emaks avatar Jul 09 '21 14:07 emaks

@leoherran-aws @josephvusich Could you take a look, please?

emaks avatar Jul 26 '21 12:07 emaks