thii / aws-codebuild-extras Goto Github PK
View Code? Open in Web Editor NEWAdd extra information of your AWS CodeBuild build via environment variables.
Add extra information of your AWS CodeBuild build via environment variables.
The variables are empty when i use the .sh file.
I obtain this error:
fatal: not a git repository (or any parent up to mount point /codebuild)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Thanks for this project
Thanks for your script ๐โโ๏ธ . Makes working with codebuild more bearable.
When building with Git clone depth set to 1, most of the variables like commit hash, branch etc are empty. If building with clone depth set to some other value, everything works fine.
I think it's worth mentioning it in the readme.
Feature request:
Can you enhance your buildspec.yml
example so that it uses the newly added environment variables in subsequent stages?
I ran into a scenario where the CODEBUILD_GIT_BRANCH was mis-identified.
A commit to main triggered a build, and a very quick commit to another branch followed. When CodePipeline and CodeBuild ran and sourced the install script, the CODEBUILD_GIT_BRANCH identified was the branch of the subsequent commit.
I am not a git expert, please bear with the rest of the issue :-)
export CODEBUILD_GIT_BRANCH="$(git symbolic-ref HEAD --short 2>/dev/null)"
if [ "$CODEBUILD_GIT_BRANCH" = "" ] ; then
CODEBUILD_GIT_BRANCH="$(git branch -a --contains HEAD | sed -n 2p | awk '{ printf $1 }')";
export CODEBUILD_GIT_BRANCH=${CODEBUILD_GIT_BRANCH#remotes/origin/};
fi
In this pipeline run, I downloaded the output zip artifact (which has the .git directory) and ran some commands...
$ git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref
So the second method is used
$ git branch -a --contains HEAD
* (no branch)
bug/4762
master
remotes/origin/bug/4762
remotes/origin/master
The commit was to master, and I think a command like the following (thank you, https://stackoverflow.com/a/52947601/1661089) might have worked better
$ git rev-parse HEAD | xargs git name-rev | cut -d' ' -f2 | sed 's/remotes\/origin\///g'
master
Is there a possibility to get label
content? e.g marking a PR with a label
and merging into branch. I would like to get label
text.
The Build Specification Reference for AWS CodeBuild states:
Do not set any environment variable with a name that begins with CODEBUILD_. This prefix is reserved for internal use.
Choose a different prefix for the added env variables?
Excellent library, thank you for making the Github branch name available inside CodeBuild! As was noted on a StackOverflow answer, it's potentially dangerous to run curl
to obtain the install script in this repo, due to the non-zero chances of an account breach. What do you think about giving mention to that concern in the README, along with a suggestion to fork the repo, so that folks who still want this solution can do so by accessing it from their own repos?
The current installation method of spawning a child shell with
bash -c "$(curl -fsSL https://raw.githubusercontent.com/thii/aws-codebuild-extras/master/install)"
does not work for making the extra env vars available to the main CodeBuild Container's environment.
When using CodePipeline as "Source provider" for CodeBuild, there's no git repo on the build instance. Therefore, none of this works :-( .
hello @thii thanks for your script. It looks great. I was wondering though, CodeBuild is famous for not storing the .git
directory which your script is dependent upon to work. How do you deal with that?
This seemed to be working a couple of weeks ago but CODEBUILD_PULL_REQUEST
always seems to be false
for me now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.