<p>The best solution we found so far, is using the <a href="https://github.com/gocd/gocd/blob/master/config/config-server/src/com/thoughtworks/go/config/MagicalGoConfigXmlLoader.java" rel="nofollow noreferrer"><code>MagicalGoConfigXmlLoader</code></a>  interface from the go source code, as it calls an internal <code>validateCruiseConfig</code> command, that does all validations, or die if the file is invalid:</p>

<pre><code>MagicalGoConfigXmlLoader loader = new MagicalGoConfigXmlLoader(new ConfigCache());
loader.loadConfigHolder(configAsString);
</code></pre>

<p>The main problem with this solution that it essentially requires the whole GoCD server source code checked out, in a working state to work properly. Also as it's an internal API it is subject to changes between GoCD versions, making GoCD upgrades harder.</p>

CC BY-SA 3.0
2017-03-03T17:52:35.087Z
2017-03-03T17:52:35.087Z
SztupY
<p>We have a GoCD installation where we like to keep the pipeline configuration XML files (<code>cruise-config.xml</code>) in a separate git repository, and install it (preferably via a pipeline and automatically) to the GoCD server whenever it is changed.</p>

<p>However we couldn't find an easy way to validate the XML config file before sending it off to GoCD, and obviously we do't want to install invalid configs, as that would break our pipelines. Are there any tools, or utilities that help us with validating the config file?</p>

CC BY-SA 3.0
2017-03-03T17:41:18.410Z
If nonne exist, I'm afraid the solution would be to write a linting program for this configuration file
Tensibai
<continuous-integration><configuration><gocd>
How can I validate GoCD configuration before applying it
SztupY
# How can I validate GoCD configuration before applying it

(Asked by: username_0 on 2017-03-03)

We have a GoCD installation where we like to keep the pipeline configuration XML files (`cruise-config.xml`) in a separate git repository, and install it (preferably via a pipeline and automatically) to the GoCD server whenever it is changed.

However we couldn't find an easy way to validate the XML config file before sending it off to GoCD, and obviously we do't want to install invalid configs, as that would break our pipelines. Are there any tools, or utilities that help us with validating the config file?

**Tags:** continuous-integration, configuration, gocd

> **Comments:**
> **username_1**: If nonne exist, I'm afraid the solution would be to write a linting program for this configuration file  

---

## 1 answers

### Answer by username_0 on 2017-03-03. Score: 4 | Accepted answer

The best solution we found so far, is using the MagicalGoConfigXmlLoader  interface from the go source code, as it calls an internal validateCruiseConfig command, that does all validations, or die if the file is invalid:
MagicalGoConfigXmlLoader loader = new MagicalGoConfigXmlLoader(new ConfigCache());
loader.loadConfigHolder(configAsString);

The main problem with this solution that it essentially requires the whole GoCD server source code checked out, in a working state to work properly. Also as it's an internal API it is subject to changes between GoCD versions, making GoCD upgrades harder.


---

