Using EB CLI to deploy a prebuilt application package. The related config.yml section looks like this:
deploy:
artifact: Website.zip
The CI build however creates a file that has the version added to it:
Website-1.5.44.zip
Is there any option to specify the deployment artifact via command like, something like this:
eb deploy --artifact "Website-1.5.44.zip"
#or
eb deploy --artifact "/path/to/Website-1.5.44.zip"
Are there any alternatives that EB CLI provides to deploy versioned build artifacts in CI pipelines? I could probably renamed the versioned zip file to just Website.zip and then run eb deploy but it would be nice to have the version be present in the artifact filename also.
Currently there is no way to do what you are describing; there are no flags to direct the EB CLI to take from a custom artifact. For now you will have to name the artifact to whatever is in your config.yml
The comment that you added will save the artifact Website.zip and name the application version Website-1.5.44.zip. It will not deploy the artifact named Website-1.5.44.zip
This python script can help you
import os
print("creating website.zip (see eb config.yml)")
os.system("cp target/"+"website-"+version+".zip target/website.zip")
print("done.")
print("Deploying Version : "+"website-"+version+" to EB.... (uploading website.zip)")
os.system("eb deploy)
It seems that in 2022 it is still not possible.
In my case I've decided to edit .elasticbeanstalk/config.yml before deployment.
This is what the configuration looks like in the file:
deploy:
artifact: build/%PACKAGE_NAME%
Command I am using to replace %PACKAGE_NAME%:
sed -i "s/%PACKAGE_NAME%/$(find build/ -name '*.zip' -printf "%f")/1" .elasticbeanstalk/config.yml
sed -i is used to replace string %PACKAGE_NAME% in file .elasticbeanstalk/config.yml with the result of find command.
The label flag will rename the file uploaded to AWS:
eb deploy --label Website-1.5.44.zip
Related
I need to make some files executable after AWS elastic-beanstalk unzip my uploaded zipped file. I need elastic-beanstalk automatically do chmod before the application can work properly such as:
sudo chmod 755 /var/www/html/mybin/executablefile1
sudo chmod 755 /var/www/html/mybin/executablefile2
How to do this properly?
You can write the commands you want to execute (including chmod) in container_commands section of your .ebextensions:
Container commands run after the application and web server have been set up and the application version archive has been extracted, but before the application version is deployed.
Alternatively, you can also use one of deployment platform hooks. For example your custom script in postdeploy:
Files here run after the Elastic Beanstalk platform engine deploys the application and proxy server. This is the last deployment workflow step.
when running this in cli, it generates the report. but when I use the same command in Jenkins, no report is generated.
newman run "C:\WORK\getMix-REST.postman_collection.json" --reporters htmlextra --reporter-htmlextra-export "C:\Jenkins\workspace\getMix_report.html"
This is the message shown in Jenkins.
newman: could not find "htmlextra" reporter
ensure that the reporter is installed in the same directory as newman
please install reporter using npm
I have verified that newman and html extra are installed in the correct directories
newman installation:
I'm stuck. please help. Thanks
**Update: when I use just newman-reporter-html instead of newman-reporter-htmlextra, it works fine and report is generated. both reporters are installed on the same level, not sure why html extra doesn't work??
The solution was as follows:
1.- Look for the folder: C: \ Program Files (x86) \ Jenkins \ tools \ jenkins.plugins.nodejs.tools.NodeJSInstallation \ Node3 \ node_modules
** Node3 may vary the name you assigned in Jenkins.
2.- Copy and paste newman and newman-reporter-htmlextra on the folder and try again.
My specific problem is that I would like to include the output of git rev-parse HEAD in a text file before deployment to ElasticBeanstalk. I believe the best way to solve it is to hook into the eb deploy command. I don't want to wrap eb deploy in a script.
I know .ebextensions defines commands that are executed on the ec2 instance during different phases of the deployment. Is there a similar utility for the client side?
I am migrating from DotCloud to Elastic Beanstalk.
Using DotCloud, they clearly explained how to set up Python Worker, and how to use supervisord.
Moving to Elastic Beanstalk, I am lost on how I could do that.
I have a script myworker.py and want to make sure it is always running. How?
Elastic Beanstalk is just a stack configuration tools over EC2, ELB and autoscaling.
One approach you can use, is create your own AMI, but since October last year, there is another approach that probably will be more suitable for your needs: ebextensions.
.ebextension is just a directory in your application, that get's detected once your application has been loaded by AWS.
Here is the full documentation: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html
With Amazon Linux 2 you need to use the .platform folder to supply elastic beanstalk with installation scripts.
We recommend using platform hooks to run custom code on your environment instances. You can still use commands and container commands in .ebextensions configuration files, but they aren't as easy to work with. For example, writing command scripts inside a YAML file can be cumbersome and difficult to test.
So you should add a prebuild hook (example) into a .platform folder to install supervisor and a postdeploy hook (example) to restart supervisor after each deployment.
There is an ini file (example) used in the script; which is made for laravel specific.
Make sure that the .sh files from the .platform folder are executable before deploying your project:
$ chmod +x .platform/hooks/prebuild/*.sh
$ chmod +x .platform/hooks/postdeploy/*.sh
I am setting up Jenkins to replace our current TeamCity CI build.
I have created a free-style software project so that I can execute a shell script.
The Shell script runs the mvn command.
But the build fails complaining that the 'mvn' command cannot be found.
I have figured that this is because Jenkins is running the build in a different shell, which does not have Maven on it's path.
My question is; how do I add the path so 'mvn' is found in my Shell script? I've looked around but can't spot where the right place might be.
Thanks for your time.
I solved this by exporting and setting the Path in the Jenkins Job configuration where you can enter shell commands. So I set the environments variable before I execute my Shell script, works a treat.
Some possible solutions:
You can call maven with an absolute path
You configure a global environment variable in the jenkins system settings with the absolute path to your maven instance, and use this in your script call (if you use the inline shell script, I don't know if those are substituted to a called script, you have to test)
You use a maven project and configure your maven instance in the jenkins system settings
ps.: Usually /bin/sh is chosen from Jenkins, if you want to switch to eg. bash, you can configure this in the jenkins system settings, in case you want to configure global environment variables.
You can use envInject plugin. It's very powerful.
I use it to install rbenv. And it can inject environment variables into your current job.
Another option to Dags suggestion is that if you're only using a single version of maven, on each slave server you could do either;
* add PATH=${PATH}:
* symlink mvn into /usr/bin with; sudo ln -s /usr/bin
I'm not at a Jenkins box at the moment, but I can find some more detailed examples if you'd like.
Jenkins is using sh by default and not bash.
This is my first time defining a jenkins maven job, and I also followed soem regular maven instructions (for running from command line...), and tried to update ~/.bashrc with M2_HOME, M2, PATH, but it didn't work because jenkins used sh and not bash. Then I found out that there is a simpler and better way built into jenkins.
After installing maven, I was supposed to configure my maven installation in jenkins.
To configure your maven installation in Jenkins:
login to jenkins web console
click Manage Jenkins --> Configure System
Under Maven, click the "Maven Installations..." button
a. Give it some name
b. and under MVN_HOME set the path to where you installed maven, for example "/usr/local/apache-maven/apache-maven-3.0.5"
Click Save button
Define a job with maven target
edit your job
Click "Add build step"
on Maven Version, enter the name you gave your maven installation (step #4 above)
set some goal like clean install