How to load git file in parameterized job in Jenkins - jenkins

So, I have a .prpoerty file on GIT that I need to load as choices in parametrized job in Jenkins any idea how can I pull a file then load it into choices.

Related

How to pull a file from git and put in workspace before the Jenkins build get started

So I'm trying to pull a file from git and put in workspace in order to load that file to be in parameterized job in Jenkins (source value) .property file in order to load choices. I need this operation to be automated. The file part

How to use a .property file from git for a parametrized job choices

I need to take from git repo a file (.properties) and use that file in a parametrized job choices to be selected by the user. any ideas? it only works with a file that exists on the same server but I need it from git repo to be chosen and put in choices.

How to let the Job DSL plugin fetch all jobs from remote Git instead of local file system?

I would like to set up many jobs automatically. In the build step "Process Job DSLs", the job-dsl plugin allows to either "Use the provided DSL script" or "Look on Filesystem" for doing its thing. While "Look on Filesystem" looks like what I'm looking for, since it allows to define multiple Job DSL files at once, it sources them from a directory on the Jenkins server. I would rather have it fetch those job specifications from a remote Git repository.
Therefore, is it possible to source all jobs from a remote Git repository? Somehow like this pseudo code?

How to add a script file in Jenkins job workspace remotely and run it as part of build step

Is it possible to add a file to Jenkins Job workspace and run it from build step.
The Jenkins is on a remote folder and I cannot directly access workspace as a folder structure.
Is there any way to achieve this from Jenkins dashboard?
Yes you can do that. In order to achieve that you can place your file in Git repository and then in the Jenkins job you can pull it and then you can execute it as a part of Jenkins job

Get Git commit from "upstream" build in manually triggered Jenkins job

I have a Build job in Jenkins that checks out a specific Git commit and packages it for deployment as artifacts.
There is a later Deployment job that takes the built artifacts and actually deploys the code. It also does a sparse Git checkout of a specific directory containing deployment scripts. After successful completion, we write a Git tag.
The problem is that the tag is being written to the HEAD of master, not to the hash of the commit used for the original upstream build. (master is the branch defined in the job configuration.)
Is there a way to get the upstream SCM information if it's not passed directly through a parameterized trigger? I can see commits listed in the build.xml file that Jenkins generates in the build directory; is there a way to read this information from the downstream job?
I realize that it's not really "downstream", since it's manually triggered. We do have a selector that defines UPSTREAM_BUILD and UPSTREAM_PROJECT, though.
If you are using the Copy Artifact plugin, you could write a file with the commit hash during the Build job and read it back in during the Deployment job:
# Build
echo ${GIT_COMMIT} > COMMIT_HASH
# Deployment, after copying COMMIT_HASH into the workspace
git checkout $(cat COMMIT_HASH)

Resources