I am using maven-docker-plugin in my project. This plugin will create docker containers during integration tests. Since drone.io put the build process inside a docker container, whether I can still use maven-docker-plugin during maven build? How to control the docker containers during build time?
If you want interact directly with the Docker daemon to create and start containers, you need to mount the host machines Docker socket into your build container.
Since you mentioned using the docker-maven-plugin you may want a configuration similar to the following:
pipeline:
build:
image: maven
environment:
- DOCKER_API_VERSION=1.20
- DOCKER_HOST=/var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- mvn clean package docker:build
Please note that exposing the Docker daemon to your build environment is essentially giving your build root access to your server. This approach is therefore not recommended for public repositories.
Please also note that volumes are restricted security reasons. To use volumes you need to have a Drone administrator mark your repository as trusted, in your repository settings screen.
So it is possible to launch containers from inside the build environment for the purpose of running your tests. The recommended approach, however, is to run your tests directly inside your build environment. This is the use case for which Drone is optimized, and it eliminates the security issues mentioned above.
Related
Sorry for the dumb question but I could not find an answer for that.
Codeship + Testim.io + Heroku.
In my Staging env - I use Testim.io to test the app once it deployed.
The following tutorial is guiding me how to invoke my tests - but I see the tests are being invoked BEFORE the new app has been deployed - so isn't it testing one version before my latest?
I expected the tests to run after the deploy.
Probably I am missing here something.
In that tutorial - the tests aren't supposed to run against your deployed version they are supposed to run against the version being tested.
The flow is:
You set up a local environment - for example by checking out your code and running npm start. If it's containerized then do that.
You run the Testim CLI and point its base url to local how testim --token ... --project ... --suite ... --base-url=localhost:PORT.
After the tests pass, you deploy.
If you test the version after you deploy you can't be sure the version deployed actually passes your tests.
An alternative flow would be to lean into Heroku's deployment model. Note this isn't actually specific to them and there are similar alternatives in aws/azure/gcp/whatever:
In your CI, you set up a staging environment in heroku heroku create --remote staging-BRANCH-NAME-<COMMIT-NAME>
You deploy there.
You run the tests against that enviroment (by passing --base-url to the Testim CLI, navigating there in your test or using a config file)
When tests pass you deploy to master
I have a self-hosted git repositories (not GitHub, not Gitlab, etc)
Is there a way to configure Drone to work with my repo ?
If you are hoping to have builds auto-triggered by push commands, Drone needs one of the following Git solutions to add webhooks to to watch for changes: https://docs.drone.io/installation/
If you just want to use a .drone.yml file and run it locally manually you can use the Drone CLI and this command: https://docs.drone.io/cli/drone-exec/
The CLI command will run just like you would build on a server, except it uses your local machine as both the server and the agent. Also all items such as secrets must be passed into the drone exec CLI command.
I am having self-hosted GitLab-EE. I want to enable CI / CD. I already have gitlab-runner on windows and it is activated for my project.
I also have custom server for hosting my ASP.NET Core 2.0 with Angular 5.0 application.
My final idea is when commit is made to GitLab, build and deploy (to custom server) is executed. Deploy path would be different if commit to master was made or any other branch (from merge request) conditional by Git Tag.
Almost all tutorials use docker, but I couldn't found why? What are the cons using docker?
I thought I only need msbuild (I can also install Visual Studio) on machine where GitLab-runner is running. It would build and deploy application. I found this configuration file which doesn't use docker, but question remains. Do I need docker and why?
A docker image would contain all the msbuild dependencies and build tools needed to build your application with out you going through the trouble of manually installing them on your server.
So basically docker helps you to manage dependencies of you application more efficiently.
I just figured out, how to release to CB hosted maven "release" repository. I am trying to figure out, how to deploy tagged version to CB application.
I understand, I can manually upload WAR file but is there any script. As far as I know maven plugin for CB doesn't support it.
I have one appserver is running snapshot builds from jenkins.
I have other appserver, which I want to deploy only tagged/released artifact.
There are four ways to deploy applications to the CloudBees RUN#cloud service:
Using the bees command provided by the SDK
Using the bees-maven-plugin
Using the manual upload via the web GUI
Using the CloudBees Deployer plugin for Jenkins
Which option you choose depends on where the deployment will take place from... And the from I am talking about is which machine is doing the deployment not where the file is sourced.
If running from a Jenkins job, the best bet is the Jenkins plugin.
If running from your own laptop, the web ui or the bees command is simplest.
If running as part of a maven build, the maven plugin is simplest... (Though I should warn that the maven plugin (temporarily removing my cloudbees hat and putting on my maven PMC hat) is shite and does it all arsewise ;-) )
Your best bet is to set up a Jenkins job that uses dependency:get to pull the artifact from the repo and then add a cloudbees deployer build step to push to RUN#cloud
The good news is that bashing the maven plugin into something more maven like is on our roadmap... Hopefully that will enable actions like you can achieve with the ship-maven-plugin#mojo where you can specify a specific released version for "shipping" to production.
I suppose, that what you want to do is to deploy a release artifact to your repository.
have a look at maven-release-plugin.
Briefly, what you need to do is:
$ mvn release:prepare
$ mvn release:perform
it's not so trivial, since you need to configure appropriately your pom.xml to get it working. Have a look at the maven-release-plugin examples and usage pages.
Are you creating the tag/release from a Jenkins build? If so you could probably use the Deploy to CloudBees post-build step with target/checkout/something.war.
More generally I guess you would want to write a script to use mvn dependency:get followed by the Bees SDK to obtain the latest released artifact and deploy it.
The spring source code examples use maven tomcat plugin and i am able to run these projects using the command mvn tomcat:run but what i dont see the application is not deployed in local tomcat server("C:\apache tomcat\webapps\")..
And how it is different from cargo plugin? (In this case when i ran the command mvn cargo:redeploy, i see the application deployed in the location "C:\apache tomcat\webapps\")
If i add cargo plugin to the POM of spring examples (like mvn-showcase,petclinic)..will it screw up the things?
The spring source code examples use maven tomcat plugin and i am able to run these projects using the command mvn tomcat:run but what i dont see the application is not deployed in local tomcat server("C:\apache tomcat\webapps\")
The command tomcat:run starts an embedded Tomcat, it doesn't deploy an application to your local Tomcat (why does it matter anyway?).
And how it is different from cargo plugin?
Cargo is a container agnostic tool so you could configure it to use a remote container, a locally installed container, an embedded container (as long as implementations are provided for a given container) and still use an unified API (or set of commands).
In this case when I ran the command mvn cargo:redeploy, I see the application deployed in the location "C:\apache tomcat\webapps\"
Cargo doesn't support running Tomcat+6.x in embedded mode. So you are very likely using it with a locally installed container and your app gets physically deployed on it.
If i add cargo plugin to the POM of spring examples (like mvn-showcase,petclinic)..will it screw up the things?
It won't screw up anything, why would it.
You can use tomcat maven plugin and deploy it to external tomcat server.
see this link for all the available goals. tomcat-run will start a embedded server but tomcat:deploy works for external tomcat.