Hello team, We upgraded JIRA to latest 8.13.4 from 7.13.3. We used to have Jenkins trigger build via JIRA transitions. After upgrade, it got broke. Looking at the article https://confluence.atlassian.com/adminjira/preparing-for-jira-8-0-955171967.html , I have updated my groovy line as required. But I still end up with error
{code}
2021-03-23 14:40:35,938 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue EDPFILECP-207 for user 'username'. View here: https://myjiraurl.com/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=Copy+of+EDPFILECP+Workflow&descriptorTab=postfunctions&workflowTransition=31&highlight=1
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.atlassian.jira.component.pico.ComponentManager()
at Script776.run(Script776.groovy:26)
My Groovy is
{code}
import com.atlassian.jira.component.pico.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
//Imports for Jenkins outage check
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.user.ApplicationUser;
import java.net.URL;
//log.setLevel(org.apache.log4j.Level.DEBUG);
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
//Custom fields
CustomField customField_Artefact_Path = customFieldManager.getCustomFieldObjectByName("ID");
CustomField customField_Project_Name = customFieldManager.getCustomFieldObjectByName("Application Name");
Issue issue = issue;
//To check the Jenkins outage
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
ComponentManager compManager = new ComponentManager();
CommentManager commentMgr = ComponentAccessor.getCommentManager();
commentMgr = (CommentManager) compManager.getComponentInstanceOfType(CommentManager.class);
def message ="";
def urlString="https://myjenkinsURL"
int status = (int) checkURL(urlString);
if ( status == 403 ) {
message = "Jenkins is Up and Runing. JIRA ticket will be updated as the deployment get progressed.";
//commentMgr.create(issue, currentUser, message, false)
log.info message;
}
else if ( status == 200 ) {
message = "Jenkins is Up and Runing. JIRA ticket will be updated as the deployment get progressed.";
//commentMgr.create(issue, currentUser, message, false)
log.info message;
} else {
message = "Jenkins is Down, Please try after some time.";
commentMgr.create(issue, currentUser, message, false)
log.info message;
}
def checkURL(urlString){
int status_code
def tempmessage=""
URL URLserver = new URL("$urlString");
try{
URLConnection connection = (HttpURLConnection)URLserver.openConnection();
status_code = connection.getResponseCode();
log.info "jenkins Status Code " + status_code;
}
catch (Exception exc){
tempmessage=exc;
log.info "Error: " + tempmessage;
}
return status_code;
}
//End of Jenkins outage check
def id=issue.getKey();
def jirareporterid=issue.reporter.name;
//Values to variables
def Artefact_Path = issue.getCustomFieldValue(customField_Artefact_Path);
def Project_Name = issue.getCustomFieldValue(customField_Project_Name).toString().trim();
//handling space in the artefact path field
def temp_path = Artefact_Path.toString().split("\\r?\\n")
String oneline = String.join(",", temp_path);
String oneline_space = oneline.replaceAll(' ','%20')
//replacing the space with the _ in project name
def edp_tenacy_name = Project_Name.replaceAll("\\s","_")
def deploymentTime;
def tag_counter;
def today = new Date()
long secondsDiff
long elapsedSeconds=0
def newDate
if (deploymentTime != null)
{
newDate = new Date().parse("yyyy-MM-dd hh:mm:ss", deploymentTime.toString())
secondsDiff = (newDate.getTime() - today.getTime()) ;
elapsedSeconds = (long)(secondsDiff/1000);
}
log.info "STimeDiff - > " + elapsedSeconds
def edpjob_url ="https://myjenkinsurl”;
log.info "Project_Name " + Project_Name
log.info "Artefact_Path " + Artefact_Path
log.info "Artefact_Path in one line" + oneline
log.info "JIRA_KEY " + id
log.info "JIRA REPORTER ID" + jirareporterid
log.info "oneline(space replaced) : " + oneline_space
log.info "EDP Tenacy Name : " + edp_tenacy_name
def JENKCRUMB
log.debug "curl -1 -k --user <myuser>:<mytoken> -H Jenkins-Crumb:45a1ff80adf741c44906b355039f7c63 -X POST $edpjob_url?delay=$elapsedSeconds&FILE_LIST=$oneline_space&APPLICATION_NAME=$edp_tenacy_name&JIRA_REPORTER_ID=$jirareporterid&JIRA_KEY=$id -H Content-Type:application/x-www-form-urlencoded"
println "curl -1 -k --user <myuser>:<mytoken> -H Jenkins-Crumb:45a1ff80adf741c44906b355039f7c63 -X POST $edpjob_url?delay=$elapsedSeconds&FILE_LIST=$oneline_space&APPLICATION_NAME=$edp_tenacy_name&JIRA_REPORTER_ID=$jirareporterid&JIRA_KEY=$id".execute().text;
{code}
Any thing else needs changed? Please advice?
-Viswa