Specify the git URL location of Jenkinsfile in a `GitHub Organization` job - github

When I create a new Github Organization job and then configure it. In the 'Project Recognizers' section I only have the ability to select 'Project Jenkinsfile' (with no input fields), which will use the Jenkinsfile in the root of each repository. I would like to be able to have a way of recognising the project but then using a different Jenkinsfile from a different GitHub repository.
I do not want the project developers to be able to modify the workflow of the project. How can I specify to use a Jenkins file from a URL location in this type of Job?

Related

Jenkins GITHUB plugin - Add repositories using groovy

I am using a Github plugin that allows scanning organization in Github and add the repos, branches, prs to Jenkins. It works perfectly and scans my branches and repo using webhook.
BUT! I want to add new repos to the existing view using regular expression using a Jenkins job.
Therefore I need to write it in GROOVY.
Does anyone know how I can modify in groovy the field of the behaviors?

No option to select existing Azure yaml file in one of our Azure DevOps projects

When creating a new Pipeline in Azure DevOps projects, for one of our Azure projects, I don't get the option to select an existing yaml file. I've compared settings with our different projects but I don't understand why the wizard jumps straight past the Configure option without ability to go back.
Specifically, after creating "New pipeline"->"Azure Repos Git"->"Select a repository" the wizard jumps straight past the Configure option to Review tab. At this point I only get the option to review my YAML file (and rename the file - no option to pick branch or existing file).
The configure screen options I'm expecting but don't get:
Any ideas why this would only be happening for certain Azure DevOps projects/repos??
Note: I have an existing yaml pipeline already in this Git repo (so do the other projects) - but even for the first pipeline I had to stuff around creating/editing/saving this file based on the default "starter pipeline" yaml file.
I couldn't find any official fix but this worked to me without having to remove any .yml files from any branch.
The URL that appears in the "Review" step looks like this:
https://dev.azure.com/{ORGANIZATION}/{PROJECT}/_apps/hub/ms.vss-build-web.ci-designer-hub?
sourceProvider=tfsgit&
telemetrySession={SESSION_ID}&
repositoryId={REPOSITORY_ID}&
repositoryName={REPOSITORY_NAME}&
branch={BRANCH_NAME}&
repositoryUrl={REPOSITORY_URL}&
sourceProviderComplete=true
Workaround: Replace branch name with a branch that has the .yml file you are looking for.
In my case ADO was putting 'Main' by default, and it didn't work until I changed it to 'Dev' which automatically redirected me to the 'Configure' tab.
I had an "azure-pipelines.yml" file in my repository root folder/all branches. It seems that once I removed this from all branches the configure option worked as expected.

If my Jenkinsfile is on repository itself, why should I specify the checkout command inside my Jenkinsfile?

I cannot figure out the philosophy of the paradigm "Pipeline script from SCM".
I create a job on Jenkins, where I specify a git repository, a branch and the name of the Jenkinsfile containing my pipeline.
I am supposed to specify, inside my Jenkinsfile, only the steps that I need to perform once the workspace is ready.
But if I omit the following step, the workspace is empty (even if I list current directory from my Jenkinsfile)
stage('checkout') {
checkout scm
}
Is there a way to avoid this by specific configuration of the Jenkins job or Jenkins itself?

Azure Devops - Multiple repositories

I have code in two github repositories that I would like to build and run in the same build pipeline.
Does anybody know if it's possible to clone/pull more than one repo during the 'get sources' step?
In Azure DevOps, a pipeline is only associated with a single repository, by default. However, there are options to include code from other Git repositories in to the build:
Add Command Line task and execute git clone with a PAT in the pipeline
Add the 2nd repository as a submodule to your primary repository. Make sure to check the 'checkout submodules' checkbox under 'Get sources' in the classic editor.
Build each repository separately and use a RELEASE pipeline to bring them together as below:
From the left menu, choose "Releases" under the "Pipeline" group. (as of 14th Oct 2019).
You will be able to add multiple artifacts to the pipeline by clicking on '+ Add'.
The screenshot below shows 3 different sources. A docker image in Azure Container Registry, A build that has output artifacts & a GitHub repository.
All the artifacts get copied to the build agent at run time in their own folders:

How to specify folder for build definition in VSTS

I have a single repository, hosted in VSTS, that contains two projects - a frontend SPA and a backend API.
I want to create separate build definitions for each.
When I go to "Create new build definition", I have an option to select the Repository source (the Team Project in VSTS), but I can't see how to specify which folder to set for each project
Multiple build definitions can have the same repository source. So, In your example, one build definition could build your frontend project and the other build definition can build your backend API project. Inside each build definition, you will create a task where you specify the required project to build. For .NET, this will probably point to the .csproj or .vbproj. For other solutions, you can just point to the folder or whatever is required for your build task.
I have an option to select the Repository source (the Team Project in VSTS), but I can't see how to specify which folder to set for each project
In this step, you just can select repository, so you just need to select a repository, after that, you can select project file for Build solution step.