0

enter image description here

I have a local instance of Jenkins. I have previously tried storing the jenkins.yml in my system and giving its path on http://localhost:8080/configuration-as-code. This worked but I want to use a Gitlab repository to store the jenkins.yml file.

I have already tried giving the gitlab link of my jenkins.yml in the path or URL textbox. Some weird things happened, like 1. jenkins broke or huge error console 2. It reapplies the previous configuration(from system path)

jenkins:
        systemMessage: "Hello, world"
d4nyll
  • 11,811
  • 6
  • 54
  • 68
Yashaswini
  • 43
  • 1
  • 5
  • According to the problem description, an usage of [pipelines](https://jenkins.io/doc/book/pipeline/getting-started/) may better suite what do you want to achieve. But you would need probably to rewrite the whole jenkins job. – Jose Camacho May 13 '19 at 18:39
  • Thanks for the response. Can you please elaborate? The only thing I wanted to do is to put the jenkins.yml file in a git repo and give the git repo link instead – Yashaswini May 13 '19 at 18:53

1 Answers1

0

Your problem as described: you want the job configuration to be saved in GIT and, when a build is triggered, the job should get the current stand of its configuration from there and then, run the build.

Maybe there is a kind of plug-in that does it for you, but I am not aware of any. Maybe anyone?

My suggestion is to define a pipeline job and use a declarative pipeline. It is a file, normally named Jenkinsfile that can be stored in GIT. In the Job, you define the GIT address and when you trigger a build, the file is got from GIT and executed.

There are several flaws in this: pipelines learning curve is not small, you are confronted with groovy (not XML!) and your current XML file is barelly useful.

Maybe someone shows up and tells us about new (for me) plugin that solves your problem using the configuration XML file. In the other hand, pipelines are such a beautyful feature that I encourage you to give it a try

Jose Camacho
  • 281
  • 2
  • 8
  • Firstly, thanks for your response. Its not the job configuration but, my idea is to automate the setup of Jenkins through yaml file which is JCasC often described as Configuration as code. Config.xml is a way of automating the Jenkins setup using XML. I am trying to achieve JCasC though. – Yashaswini May 14 '19 at 15:14