New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional statements in buildspec.yml #2
Comments
This is in a 0.2 version of buildspec.yml but we're just testing the ARN from the Codebuild process itself for a substring, and based on that running a different build command. This uses multiline capability of the yaml file Example Arn that we're evaluating |
|
@ktwbc works great, but is it possible to get an I'm trying to get different path of execution based on whether or not it is a PROD environment build. |
|
@payne911 honestly just save yourself some hassle and build out a regular bash script as a separate file and call it from buildspec.yml Example if you put all your bash code into a file in your repo under /aws/myscript.sh then chmod a+x before you check it in, then all you have to do is: pre_build: And now you can just call your script in the commands: now that you're in your own bash instead of their buildspec format it makes all that easier and you still have access to all the environment variables. One word of warning. setting any new variables like export MY_VAR= whatever in your separated bash won't be passed back to buildspec to be used later. |
|
Okay. |
|
If you export it within (myscript.sh) script it will be inherited from codebuild bash shell too myscript.sh: #!/bin/bash
export CODEBUILD_BUILD_SUCCEEDING=truesource ./myscript.sh echo ${CODEBUILD_BUILD_SUCCEEDING} Use source instead of "." |
Hi,
Would somebody be able to provide an example on how to use Conditional statements such as "if else statements" in a buildspec.yml.
Thanks in advance
The text was updated successfully, but these errors were encountered: