@@ -148,11 +148,11 @@ public void basicsPipeline() throws Exception {
148148 String alias = "androiddebugkey" ;
149149 String password = "android" ;
150150 StandardCertificateCredentials c = new CertificateCredentialsImpl (CredentialsScope .GLOBAL , "my-certificate" , alias ,
151- password , new CertificateCredentialsImpl .FileOnMasterKeyStoreSource ( certificate . getAbsolutePath () ));
151+ password , new CertificateCredentialsImpl .UploadedKeyStoreSource ( new FileParameterValue . FileItemImpl ( certificate ), null ));
152152 CredentialsProvider .lookupStores (r .jenkins ).iterator ().next ().addCredentials (Domain .global (), c );
153153 // create the Pipeline job
154154 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
155- String pipelineScript = IOUtils . toString ( getTestResourceInputStream ( "basicsPipeline-Jenkinsfile" ), StandardCharsets . UTF_8 );
155+ String pipelineScript = getTestResourceAsUTF8String ( "basicsPipeline-Jenkinsfile" );
156156 p .setDefinition (new CpsFlowDefinition (pipelineScript , true ));
157157 // copy resources into workspace
158158 FilePath workspace = r .jenkins .getWorkspaceFor (p );
@@ -170,13 +170,20 @@ private InputStream getTestResourceInputStream(String fileName) {
170170 return getClass ().getResourceAsStream (getClass ().getSimpleName () + "/" + fileName );
171171 }
172172
173+ private String getTestResourceAsUTF8String (String resourceName ) throws IOException {
174+ try (InputStream is = getTestResourceInputStream (resourceName )) {
175+ return IOUtils .toString (is , StandardCharsets .UTF_8 );
176+ }
177+ }
178+
173179 private FilePath copyTestResourceIntoWorkspace (FilePath workspace , String fileName , int mask )
174180 throws IOException , InterruptedException {
175- InputStream in = getTestResourceInputStream (fileName );
176- FilePath f = workspace .child (fileName );
177- f .copyFrom (in );
178- f .chmod (mask );
179- return f ;
181+ try (InputStream in = getTestResourceInputStream (fileName )) {
182+ FilePath f = workspace .child (fileName );
183+ f .copyFrom (in );
184+ f .chmod (mask );
185+ return f ;
186+ }
180187 }
181188
182189}
0 commit comments