Share script to multiple gitlab ci - gitlab-ci

I use GitLab CI.
I have a script used in the CI of multiple repository.
I want to use it without duplicating it in each repository, how should I proceed ?

You can create a Project that contains all your shared/common scripts; you can then just use that project - eg. do a git clone in the before_script on that project and you can then use those shared/common scripts.

You can use multipipeline feature of Gitlab. Basically, create a repository with the pipeline and call it in another.
Here is the docs for it:
https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html

Related

Can I deploy bamboo.yml YAML specs manually?

I am trying to learn how YAML specs works in Bamboo. So far I achieved to deploy the plan following the official documentation. enter link description here
The documentation explains that you need to create a bitbucket repository, create bamboo.yml, set a new project in bamboo, enable a bamboo specs repository and finally you get your plan created and based in YAML specs.
My question is, can I create a plan.yml and deploy it from other bamboo plan?
For example, for JAVA specs, it is enough to checkout a repo with several *.java specs files and use maven and a pom file to deploy all the plans.
Can I do something similar with YAML specs? To have a folder in some SCM with several *.yml files and deploy them simultaneously. As a result, to have a lot of plans in bamboo deployed and based on the yml files.
yes and no, yaml can't be sent to the server as you can do with java specs. It needs to be committed to the repo first
you also need to have your different project created prior to committing the yaml specs and or have that repo granted access to each individual project or enabled the flag on the linked repo to allow access to all projects in the specs tab.
if this is not an issue,then yes there is no problem defining multiple plans in your bamboo specs yml file, even across multiple projects, as long as they are split up in separate yaml documents (with "---")

One Repository With Multiple Deployments, Environment Variables, and Secrets on Vercel?

I'm doing some early research for a project I plan to deploy to Vercel. I am wondering if the following is possible:
I want to have on GitHub repository. This repository will use environment variables for API tokens, and basic settings.
I have three versions of the project that I want to create. Instead of creating three separate repositories, I'd rather have one repository, and then have the slight differences made using environment variables. This will make updates, fixes, etc much easier.
So, my question is: Is it possible to deploy one repository three times, each with different environment variables, using Vercel?
Yes, possible in deploying multiple environments in 1 repository. This can be done by importing your project to Vercel. For evey commit you made on the git repo, there is a completely new environment created for that. See https://vercel.com/docs/v2/git-integrations
You may also opt to create different git branches for each environment, and Vercel will take care in creating new environment for them. See https://vercel.com/docs/v2/git-integrations/vercel-for-github#a-deployment-for-each-push
With regards to environment variables, here's what the doc says:
The maximum number of Environment Variables per Environment per Project is 100. For example, you can not have more than 100 Production Environment Variables.
Moreover, the total size of Environment Variables applied to a Deployment (including all the Environment Variables Names and Values) is limited to 4kb. Deployments made with Environment Variables exceeding the 4kb limit will fail during the Build Step.
- https://vercel.com/docs/v2/platform/limits?query=environment%20va#environment-variables
Environment Variables: https://vercel.com/docs/v2/build-step#environment-variables
Yes, they give you Production, Preview, and Development environments. Each has their own environment variables you can save via the UI, or you can download the .env via the cli with vercel env pull.
https://vercel.com/docs/build-step#environment-variables
Multiple Vercel projects can be created for the same GitHub repo.
In other words, there is no restriction like only a single Vercel project can be created for the single GitHub repo.
Then, different environment variables can be set for different Vercel projects.
Pushing a commit to the GitHub repo triggers build & deploy of multiple Vercel projects.
Referece: https://github.com/vercel/vercel/discussions/4879#discussioncomment-356114

Upload non java artifacts to nexus 3.1.0-04

I want to be able to upload a non java artifact to hosted nexus3 repository. For this I used the curl commands described in this link uploadToNexus, but it worked only for nexus 2. I noticed also that we can create groovy script, upload them to nexus and run them (RestApi, but I'm not sure if we can create a groovy script to upload artifacts. Is there a groovy script giving this possiblity ? I'm wondering also if there is any non maven alternative to the maven deploy plugin ?
Thanks in advance.
If it's a non Java artifact, you might look at using our RAW repository, depending on what it is. However, if you for sure want to use a Maven repository, the good news is you can :)
Assuming you have a fairly normal local setup, go with something akin to this. The big change between Repository Manager 2 and 3 is that the endpoints changed, which is why the old commands are not working for you.
curl -v -u admin:admin123 --upload-file file.jar http://localhost:8081/repository/releases/org/foo/1.0/file.jar

How to select the particular repository in bamboo during build?

I am new to use the bamboo server. In the application, i have multiple branches, during the build time, it is possible to normal user to select the particular branch to build other than default repository.
Thanks in advance
You can use plan branches to build for specific or all branches. See https://confluence.atlassian.com/display/BAMBOO/Using+plan+branches for more details.

maven build execute svn get

I have a project build that needs to include files from another svn location during the build. I want to execute an svn get and then copy these files to the appropriate folder for the build. Researching this issue it seems I could use ant tasks but I wanted to find out what might be the best approach to take for this build.
You can use the maven-scm-plugin. According to the scm matrix both checkout and update are allowed.
Robert's answer is good, if the project is large though you'll be checking out a lot of content to get e single file.
If you want to get an individual file from SCM, the Maven SCM API allows you to interact directly with an SCM repository to invoke arbitrary goals. In this related answer I provide an example of a custom Mojo that commits a single file, if you implement that mojo and change the command from add to checkout you'll avoid having to checkout the entire project.