1

I have a bulk of Jenkins jobs for each release we issue. I want to be able to easily define a new release, and was happy to find Folder properties Pluging

I defined a folder property for the version:

folder property definition

After that I defined a try job, which use the folder defition, and echos it's value.

job description (freestyle).

I run it, and get the value on log:

version: master
    echo 'folder version: master'
    folder version: master
    Finished: SUCCESS

Now, I added an SCM definition to the job:

scm definition

But I get error on log. As you can see $folder_version did not get the "master" value.

git rev-parse refs/remotes/origin/$folder_version^{commit} # timeout=10
git rev-parse refs/remotes/origin/refs/heads/$folder_version^{commit} # timeout=10
git rev-parse refs/heads/$folder_version^{commit} # timeout=10
   ERROR: Couldn't find any revision to build. Verify the repository and        branch configuration for this job.

What am I missing here?

1
  • Trying to set the branch for your git repo clone at a local folder level is VERY desirable. Surprised that this did not work. I know that if you have system admin level access in your Jenkins you can add global variables that will get used for defining the checkout branch for git (even in a classic job). However, that would not be practical for most. Especially in a large corporate setting where very few have access to set global variables. Plus you may have different job sets in different folders and it would be a poor process to have a unique variable for every folder. Is there a chance of u
    – JamesW
    Nov 14, 2019 at 22:30

1 Answer 1

0

Thank you for using my plugin. About your question, I believe in a freestyle job, the SCM step does not try to interpolate the selector string and so you can see the console output will render this:

git rev-parse refs/remotes/origin/origin/$folder_version^{commit} # timeout=10

Where the $folder_version is the intended place-holder not interpolated.

As an alternative, switch to Pipeline jobs and do something like this:

stage('Test SCM'){
    node{
        withFolderProperties{
            echo("Branch is '${env.folder_version}'")
            git branch: env.folder_version, credentialsId: 'my-github-credentials', url: 'https://github.com/my-org/my-project.git'
            isUnix()?sh('ls -la'):bat('dir')
        }
    }
}

I hope this helps.

4
  • HI, Thanks for the plugin, and for the answer. Actually, I wrote this "trial" job just to debug the bigger issue, and for the question here. My target is having a declarative pipeline. I want to specify the branch from where to take the pipeline source. So I need it at the Jenkins SCM level. I have about 25 jobs for each release (I'm in the process of re-arrange them, but this is what I have now), so I wanted to define the version (branch) in a single place.
    – hagits
    Oct 27, 2018 at 14:13
  • 1
    Hi, Thanks for the answer. It does not helps a lot. I need to set the branch from which to take the pipeline script. This is done on jenkins, before I call the pipeline. It means that when I define a new release, I have to go through bunch of jobs, and define the version in them one by one, instead of setting the version in the folder. We like pipelines, as in this way we have good source control on changes, and the ability to re-use code.
    – hagits
    Nov 27, 2018 at 16:02
  • Indeed it doesn't help, @hagits were you able to find another solution? I'm facing the same exact problem.
    – Alex Weitz
    Nov 7, 2019 at 4:16
  • No. Didn't find a good solution. I just go over a few jenkins jobs that I create for a new release, and update a local property in there... No satisfied, but I can live with it.
    – hagits
    Nov 27, 2019 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .