How to properly set an AWS Codebuild conditional build - amazon-web-services

In AWS Codebuild's build project I am trying to set my FILE_PATH "Don't start a build under these conditions." However, I can't get it to work.
how would I go about setting the proper regex that the aws build project will recognize?
info
Source Provider: GitHub
Event type: Push
Commits to this file should not trigger a build: README.md
I don't believe amazon is following the traditional regex pattern but here is a picture what I currently have (I based it on the documentation where they have ^buildspec.*). Also this is just an example I want to get working before I move on, the real requirement is to list multiple files to be ignored by my build project.
P.S. I tried read this post but still could not figure it out. Specify file_path while triggering AWS codebuil

Related

Azure DevOps Pipeline: AWS CLI Task, How to reference predefined variables

I am using the AWS CLI task to deploy a Lambda layer. The build pipeline upstream looks like this:
It zips up the code, publishes the artifact and then downloads that artifact.
Now in the release pipeline I'm deploying that artifact via an AWS CLI command. The release pipeline looks like this:
I'm trying to figure out a way to dynamically get the current working directory so I don't need to hardcode it. In the options and parameters section you can see I'm trying to use $(Pipeline.Workspace) but it doesn't resolve correctly.
Is this possible?
Correct me if I am wrong, but I looks like you are running this in Azure Release? Not Pipelines?
If that is the case I think the variable you are looking for is $(Release.PrimaryArtifactSourceAlias) .
See the section of the document that talks about release specific variables: https://learn.microsoft.com/en-us/azure/devops/pipelines/release/variables?view=azure-devops&tabs=batch#default-variables---release
Yes. This is completely achievable.
From your screenshot, you are using the Release Pipeline to deploy the Artifacts.
In your situation, the $(Pipeline.Workspace) can only be used in Build Pipeline.
Refer to this doc: Classic release and artifacts variables
You can use the variable: $(System.ArtifactsDirectory) or $(System.DefaultWorkingDirectory)
The directory to which artifacts are downloaded during deployment of a release. The directory is cleared before every deployment if it requires artifacts to be downloaded to the agent. Same as Agent.ReleaseDirectory and System.DefaultWorkingDirectory.

Aws Code pipeline is failing at Deployment stage by timing out

I am trying to work my way to have a ci/cd for the Api part of the application.
I have 3 steps:
1: Source (git hub version2)
2: Build (currently has no commands)
3: Deploy(provider is code deploy(application))
Here is the screenshot of the events in code deploy.
.
While creating the Deployment Group. I chose the option of downloading the code deploy provider from the option(though it was necessary).
While setting up the code pipeline chose
Felt that was appropriate.
This code pipeline has put an object into the S3 bucket for this pipeline.
Code deploy is acting on that source artifact.
Note:
We have nothing on this Ec2 image it's just a place where we have our API.
Currently, Ec2 is empty.
What would be the proper way to implement this? How can I overcome the issues I am facing.
Without appspec.yml your deployment will fail. From docs:
An AppSpec file must be a YAML-formatted file named appspec.yml and it must be placed in the root of the directory structure of an application's source code. Otherwise, deployments fail.

Is it possible to call Google Cloud Build via API with cloudbuild.yaml in source repo

I have an Cloud Build trigger that is set up to fetch a specific branch from a remote repository and use the cloudbuild .yaml file from it to run the build. I need to do the same programatically via an API call and the only way I can see this happening is with an API call here: https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds/create.
By looking at the required request body which is of type Build https://cloud.google.com/cloud-build/docs/api/reference/rest/Shared.Types/Build it seems that while I can provide the source repository (branch, commit or tag) I'm not sure how to provide the path to cloudbuild.yaml which in this case really needs to sit with the repo source code. Also it seems a steps param is required which actually has to be the steps from the cloudbuild file.
Is there any way that I can create a build using the same resources that I would otherwise set up in a cloud trigger (path to (cloudbuild.yaml instead of the steps to which I don't have access to in this case)?

VSTS Yaml Build - App Center Service Endpoint could not be found

I'm trying to setup my build definition with YAML. I'm using the AppCenterDistribute task. It requires and endpoint to MS App Center. I've setup one as per this tutorial.
However, I got that error message:
"Step input serverEndpoint references endpoint Appcenter which could not be found. The service endpoint does not exist or has not been authorized for use."
This is exactly the same issue as this post although I've made sure that I AM in the correct VSTS project.
What could be the problem? I can't even run my build now.
Here's the YAML section:
variables:
APKName: 'com.project.this.apk'
- task: AppCenterDistribute#1
displayName: Deploy APK to App Center
inputs:
serverEndpoint: Appcenter
appSlug: 'Project/Learn'
appFile: '$(build.artifactstagingdirectory)\$(APKName)'
symbolsIncludeParentDirectory: false
releaseNotesInput: Notes
Note that I do have a normal VSTS web build (with a slightly different name) in the same VSTS project that does build and can distribute using the same endpoint to App Center.
Here's the error when I submit a YAML build:
I can also reproduce the issue when the App Center Distribute task is added in a YAML build definition.
And I also create an issue App Center Distribute task show errors when queuing YAML build for it. You can follow up.
You followed the App Center tutorial but you still have to create the Endpoint in VSTS which I think is what you're missing. It cannot be done through your Yaml.
To do so, connect to VSTS and start creating a new empty-process build definition MANUALLY for the SAME project. Add the the "App Center Distribute" task. There is a dropdown for the endpoint. It is empty and there is a "New" button to create one. Do so and give it the name that you use in your Yaml. Then you can cancel your build definition creation and use your Yaml.
UPDATE:
I replied too fast as you said you already have a build defintion working fine with your App Center endpoint. I still keep the above as it could help others.
However, when I compare your Yaml to mine, I notice that I use quotes while you don't. That may be the issue (also I may just have quotes because I have a space in my endpoint name and you don't).
serverEndpoint: 'App Center'
On your existing working build definition, did you try the "View Yaml" button on the top right corner? This gives you the corresponding yaml and it is very useful :-)

Use two sources in an AWS-CodePipeline pipeline

I have a specific case which I'm not sure if it's possible with AWS CodePipeline, and I didn't find any information about it in the documentation and event by googling....
So I would like to know if I can set two sources in a pipeline (it could be in the same stage or different stages).
Here is my use case :
I would like my pipeline to start when a file (a specific object) is modified in my s3 bucket
When this file changes and the pipeline is triggered, I would like to clone a codecommit repository and then process the build and other stages...
In the other hand when there is a commit on the master branch of my codecommit repository, I would like the pipeline to start and build my sources.
So The pipeline should be triggered either when the change comes from s3 or codecommit
I don't want to version the s3 file in my codecommit repository because it should be encrypted and used by others teams than dev team working with the git repository
And any time my pipeline starts either if it's from the s3 bucket change or the codecommit push, I should source the commit from the repository for build purposes...
I don't know if my objectives specifications are clear, if yes is it possible to use two source actions in a pipeline as described above and how to achieve this?
Thank you in advance.
Cheers,
Eugène NG
Yes. It is possible to have two sources for an AWS CodePipeline. Or many for that matter. The two sources have to be in your first stage.
Then in your build phase properties, you need to tell it that you are expecting two sources.
Then tell the build project which is your primary source. This is going to be the one that you want your build project to execute the codebuild.
From your buildspec or from any scripts you call, you can then access the source directories by referencing:
$CODEBUILD_SRC_DIR_SourceOutput1
$CODEBUILD_SRC_DIR_SourceOutput2
Just replace SourceOutputX above with what you call your output from the source stage.
I found the following link with more information:
https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
Yes, CodePipeline allows multiple source actions in a single pipeline. A change in either source will trigger a pipeline execution. The thing to know is that every pipeline execution will pull the latest source for both actions (not just the one with a change that triggered the pipeline execution).