awslabs / aws-codepipeline-plugin-for-jenkins

Use this plugin to integrate your Jenkins project with a pipeline in AWS CodePipeline. For more information and step-by-step directions on how to install and configure this plugin, follow the Four Stage Pipeline Tutorial. http://docs.aws.amazon.com/codepipeline/latest/userguide/getting-started-4.html
Apache License 2.0
82 stars 68 forks source link

Expose artefact revision to Build Commands #4

Open jinty opened 9 years ago

jinty commented 9 years ago

Hi,

I've just started using CodePipeline with Github as source and Jenkins to build. However I find it impossible to get the git commit id from within the jenkins builder. I have a few uses for this:

It would be great if I could access in the job, as an environment variable, the git commit id (or revision as it is called here: http://docs.aws.amazon.com/codepipeline/latest/APIReference/API_Artifact.html)

biagic commented 9 years ago

Hi Brian,

Thank you for the feedback. We are working this (the Revision of an Artifact from a GitHub source action will be the git commit id), and we'll update this issue when it's ready.

fabiosantoscode commented 8 years ago

I'm affected as well. Our healthcheck used to contain the current commit hash and message, now it doesn't :(

rangaataws commented 8 years ago

Thank you for the feedback. The revisionId (Git SHA of GitHub or CodeCommit) is now returned in Artifact instance for all input artifacts in JobData of the Build or Deployment action. If your source action is of type Amazon S3, the revisionId is going to be Amazon S3 object VersionId. http://docs.aws.amazon.com/codepipeline/latest/APIReference/API_Artifact.html http://docs.aws.amazon.com/codepipeline/latest/APIReference/API_JobData.html

Thanks,

biagic commented 8 years ago

Now that PollForJobs and GetJobDetails return the revisionId (jobDetails.data.inputArtifacts[].revisionId), the plugin should expose them as environment variables, so they can be used when the job executes. For example:

# Input artifact names
CODE_PIPELINE_INPUT_ARTIFACTS=(InputOne InputTwo)
# Revision IDs
CODE_PIPELINE_REVISION_ID_InputOne=f018e28d56a5dae955b75eb1ea238304a6829f33
CODE_PIPELINE_REVISION_ID_InputTwo=8b1dfbce24c311df06c2c1b921de75e2db236338

For jobs with a single input artifact (most common use case), it might be convenient to use a fixed variable name:

CODE_PIPELINE_REVISION_ID=f018e28d56a5dae955b75eb1ea238304a6829f33
ghost commented 7 years ago

Hi, Any chance to get Commit_ID inside Jenkins job? Looks like it is still not implemented...