File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
src/main/kotlin/io/codemc/api/jenkins Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,25 @@ internal suspend fun createCredentials(username: String, password: String): Bool
9595 * @return `true` if the password was changed, `false` otherwise.
9696 */
9797fun changeJenkinsPassword (username : String , newPassword : String ): Boolean = runBlocking(Dispatchers .IO ) {
98+ // Create Credentials Domain
99+ val checkDomain = req(" ${jenkinsConfig.url} /job/$username /credentials/store/folder/domain/Services/config.xml" ) {
100+ GET ()
101+
102+ header(" Authorization" , " Basic ${client.authValue()} " )
103+ }
104+
105+ if (checkDomain.statusCode() == 404 ) {
106+ val domainConfig = RESOURCE_CACHE [CREDENTIALS_DOMAIN ] ? : return @runBlocking false
107+ val domain = req(" ${jenkinsConfig.url} /job/$username /credentials/store/folder/createDomain" ) {
108+ POST (HttpRequest .BodyPublishers .ofString(domainConfig))
109+
110+ header(" Authorization" , " Basic ${client.authValue()} " )
111+ header(" Content-Type" , " application/xml" )
112+ }
113+
114+ if (domain.statusCode() != 200 ) return @runBlocking false
115+ }
116+
98117 val config = (RESOURCE_CACHE [CREDENTIALS ] ? : return @runBlocking false )
99118 .replace(" {ID}" , NEXUS_CREDENTIALS_ID )
100119 .replace(" {DESCRIPTION}" , NEXUS_CREDENTIALS_DESCRIPTION )
You can’t perform that action at this time.
0 commit comments