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

Artifacts download to workspace on Jenkins master rather than slave

Open stewartn782 opened this issue 2 years ago • 0 comments

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

stewartn782 avatar Aug 11 '21 10:08 stewartn782