/** * Creates a new variable. * * @param projectId The ID of the project containing the variable. * @param variable The variable to create. * @return The newly created variable. */ public GitlabBuildVariable createBuildVariable(Integer projectId, GitlabBuildVariable variable) throws IOException { String key = variable.getKey(); String value = variable.getValue(); return createBuildVariable(projectId, key, value); }
/** * Deletes an existing variable. * * @param projectId The ID of the project containing the variable. * @param variable The variable to delete. * @throws IOException on gitlab api call error */ public void deleteBuildVariable(Integer projectId, GitlabBuildVariable variable) throws IOException { deleteBuildVariable(projectId, variable.getKey()); }
/** * Deletes an existing variable. * * @param projectId The ID of the project containing the variable. * @param variable The variable to delete. * @throws IOException on gitlab api call error */ public void deleteBuildVariable(Integer projectId, GitlabBuildVariable variable) throws IOException { deleteBuildVariable(projectId, variable.getKey()); }
/** * Creates a new variable. * * @param projectId The ID of the project containing the variable. * @param variable The variable to create. * @return The newly created variable. */ public GitlabBuildVariable createBuildVariable(Integer projectId, GitlabBuildVariable variable) throws IOException { String key = variable.getKey(); String value = variable.getValue(); return createBuildVariable(projectId, key, value); }
/** * Deletes an existing variable. * * @param projectId The ID of the project containing the variable. * @param variable The variable to delete. * @throws IOException on gitlab api call error */ public void deleteBuildVariable(Integer projectId, GitlabBuildVariable variable) throws IOException { deleteBuildVariable(projectId, variable.getKey()); }
/** * Creates a new variable. * * @param projectId The ID of the project containing the variable. * @param variable The variable to create. * @return The newly created variable. */ public GitlabBuildVariable createBuildVariable(Integer projectId, GitlabBuildVariable variable) throws IOException { String key = variable.getKey(); String value = variable.getValue(); return createBuildVariable(projectId, key, value); }
@Test public void testCreateUpdateDeleteVariable() throws Exception { String key = randVal("key"); String value = randVal("value"); String newValue = randVal("new_value"); String projectName = randVal("project"); GitlabProject project = api.createProject(projectName); assertNotNull(project); GitlabBuildVariable variable = api.createBuildVariable(project.getId(), key, value); assertNotNull(variable); GitlabBuildVariable refetched = api.getBuildVariable(project.getId(), key); assertNotNull(refetched); assertEquals(refetched.getKey(), variable.getKey()); assertEquals(refetched.getValue(), variable.getValue()); api.updateBuildVariable(project.getId(), key, newValue); GitlabBuildVariable postUpdate = api.getBuildVariable(project.getId(), key); assertNotNull(postUpdate); assertEquals(postUpdate.getKey(), variable.getKey()); assertNotEquals(postUpdate.getValue(), variable.getValue()); assertEquals(postUpdate.getValue(), newValue); api.deleteBuildVariable(project.getId(), key); // expect a 404, but we have no access to it try { GitlabBuildVariable shouldNotExist = api.getBuildVariable(project.getId(), key); assertNull(shouldNotExist); } catch (FileNotFoundException thisIsSoOddForAnRESTApiClient) { assertTrue(true); // expected } api.deleteProject(project.getId()); }
@Test public void testCreateUpdateDeleteVariable() throws IOException { String key = randVal("key"); String value = randVal("value"); String newValue = randVal("new_value"); String projectName = randVal("project"); GitlabProject project = api.createProject(projectName); assertNotNull(project); GitlabBuildVariable variable = api.createBuildVariable(project.getId(), key, value); assertNotNull(variable); GitlabBuildVariable refetched = api.getBuildVariable(project.getId(), key); assertNotNull(refetched); assertEquals(refetched.getKey(), variable.getKey()); assertEquals(refetched.getValue(), variable.getValue()); api.updateBuildVariable(project.getId(), key, newValue); GitlabBuildVariable postUpdate = api.getBuildVariable(project.getId(), key); assertNotNull(postUpdate); assertEquals(postUpdate.getKey(), variable.getKey()); assertNotEquals(postUpdate.getValue(), variable.getValue()); assertEquals(postUpdate.getValue(), newValue); api.deleteBuildVariable(project.getId(), key); // expect a 404, but we have no access to it try { GitlabBuildVariable shouldNotExist = api.getBuildVariable(project.getId(), key); assertNull(shouldNotExist); } catch (FileNotFoundException thisIsSoOddForAnRESTApiClient) { assertTrue(true); // expected } api.deleteProject(project.getId()); }