Ask a Question

OAUTH2.0 Implementation is not working in Jenkins

madhankumarbs
Occasional Contributor

OAUTH2.0 Implementation is not working in Jenkins

I have created the OAUTH2.0 profile as specified in ReadyAPI support page and also included a Groovy Script to get the fresh token always. It all works perfectly in local but in Jenkins it is throwing the error

2 REPLIES 2
nmrao
Community Hero

Please try to add more logging in your script and see where it causing issue if the present log is not helpful.


Regards,
Rao.
madhankumarbs
Occasional Contributor

Have attached the Logs.. 

 

 

I have created a OAUTH Profile and added Automation Scripts in the Scripts tab to have it accessed everytime the token needs to be refreshed. 

I have a REST steps which demands OAUTH

I have added the below code in RequestFilter.filterRequest Event

 

// Import the required classes
import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade;
import com.eviware.soapui.support.editor.inspectors.auth.TokenType;
import com.eviware.soapui.model.support.ModelSupport;
import com.teamdev.jxbrowser.*;

// Get a project
def project = ModelSupport.getModelItemProject(context.getModelItem());

// Get the needed authorization profile
def authProfile = project.getAuthRepository().getEntry("My Profile");

//Create a facade object
def tokenType = TokenType.ACCESS;
def oAuthFacade = new OltuOAuth2ClientFacade(tokenType);

// Request an access token in headless mode and assign it to the authorization profile we got earlier
oAuthFacade.requestAccessToken(authProfile, true, true);

// Access token retrieval may take time, so we need to pause the execution for 3 seconds to finish it. You may increase this value if needed.
sleep(3000);

// Posts a new token to the script log
log.info("Set new token: " + authProfile.getAccessToken());

 

I have tried the same with SubmitListener.beforeSubmit Event as well

 

Both works perfectly in Local windows machine. However when I trigger the job in jenkins (linux) it throws the error that chromium is not intialised

 

 

 clean test -Djxbrowser.chromium.dir=/apps/jenkins-agent/.m2/repository/com/teamdev/.jxbrowser -Djava.awt.headless=false is my MVN command in Jenkins

 

cancel
Showing results for 
Search instead for 
Did you mean: