create new Project with versioned settings per REST API

Answered

Hi there,

 

we have a workflow for creating new Projects in Teamcity.

1. we create a new Gitlab repository which contains the .teamcity kotlin directory

2. we create a new project via rest api

3. add a vcs root for this project per rest api

4. enable versioned settings with the vcs root (step 3) for the project

 

this works fine, but we cant force loading project settings from VCS.

After creating the Project, it is empty in Teamcity but has a working project settings in the repo.

 

If i disable the synchronization -> enable it again -> click apply -> in the popup click "import from vcs"

the project settings are loading and the projects is displayed in the Teamcity UI

 

is there a way to force the import by sending the request for the new projectFeature (versioned settings)?

 

currently i send

POST [TEAMCITY_API_URL]/projects/[PROJECT_ID]/projectFeatures

 

<projectFeature type="versionedSettings" >
<properties count="7">
<property name="buildSettings" value="PREFER_VCS" />
<property name="credentialsStorageType" value="credentialsJSON" />
<property name="enabled" value="true" />
<property name="format" value="kotlin" />
<property name="rootId" value="[VCS_ROO_ID]" />
<property name="showChanges" value="false" />
<property name="useRelativeIds" value="true" />
</properties>
</projectFeature>

 

In my browser dev tools there is an addition property in the request. Adding this property doesn't make a difference


<property name="confirmation" value="import" />

 

3 comments
Comment actions Permalink

Hi,

I'm afraid it's not possible to trigger the resync of versioned settings via REST API. We have the following feature request you can vote for and follow the updates: https://youtrack.jetbrains.com/issue/TW-58754

As a workaround you can try sending a simple POST request to: http://teamcity:8111/admin/versionedSettingsActions.html with the following data:

{
"action": "loadProjectSettings",
"projectId": "ProjectID"
}

Just replace ProjectID with the ID of your project. 

Make sure you're sending Authorization header along with this request.

 

Best regards,

Mikhail Efremov

1
Comment actions Permalink

Hi,

 

the request reloads the settings, but with the same output.

 

Cannot find previous revision of project: [PROJECT_ID], skip updating settings to revision bfc42cf5c81c6117e9b752f8055a2876f3f09066. Please commit current project settings into VCS first.

 

0
Comment actions Permalink

Hi, sorry for the delay with the response. I've been trying to reproduce your issue without success.

I followed your steps: created a blank project, attached the VCS root with versioned settings and sent the REST call to /projectFeatures with exactly the same query.

Right after the REST query I've seen the same message: 

But it has quickly changed to:

Then I sent the above HTTP request to /versionedSettingsActions.html and the settings were successfully loaded:

 

 

I assumed that maybe you were sending the HTTP request right after the REST call? Try adding a delay and let the server collect the changes first.

Best regards,

Mikhail Efremov

0

Please sign in to leave a comment.