craigwongva / pfeiffer4building

0 stars 0 forks source link

Pipeline doesn't talk to Jenkins #2

Open craigwongva opened 6 years ago

craigwongva commented 6 years ago

BTW, if this Jenkins doesn't work because of the above issue, then this blog post also has a CloudFormation script for setting up a Jenkins: Setting up the Jenkins plugin for AWS CodeDeploy

12/6/17: I used the above Amazon blog to launch an instance, but its Jenkins failed right away.

Upon sudo service jenkins restart the error said "jenkins something but pid file exists".

Upon sudo service jenkins stop and then sudo service jenkins start the error said Unsupported major minor or something like that that led me to believe the Java version was wrong. So I used key chunks of pfeiffer4building userdata that I had just run a few days ago:

Upon sudo service jenkins start it started fine and was accessible from the web.

-- 1006 aws codepipeline list-action-types --region us-west-2 1007 aws codepipeline delete-custom-action-type --category Test --provider Jenkins --action-version 1 --region us-west-2

--

Successfully got CodeDeploy talking to Jenkins (had to install CodeDeploy plugin in Jenkins manually, and the above installation weirdness, though). The key Lesson Learned is that the Provider that is requested in CodePipeline is set in the Jenkins job, when you click on AWS CodePipeline it then drops open some parms including what you want to name your Jenkins AWS CodePipeline usage. The documentation says you just configure your Jenkins AWS CodePipeline plugin, but you['re not really configuring the plugin, you are configuring the job use of the plugin.

BTW the deployment is probably failing right now because I used 4b's deployment app and deployment group, and the non-existent output from Jenkins (it's just an echo statement because I couldn't get rake installed properly) won't know how to deploy to 4b.

--

AWS CodePipeline Plugin] Polling for jobs for action type id: [Owner: Custom, Category: Build, Provider: JenkinsThu, Version: 1, ProjectName: BuildProject]
ERROR: Failed to record SCM polling for hudson.model.FreeStyleProject@6a7382ce[BuildProject]
com.amazonaws.services.codepipeline.model.AWSCodePipelineException: User: arn:aws:sts::994238729631:assumed-role/JenkinsCodeDeploy-JenkinsRole-1UF0A9LV57FAU/i-065da98d8b3c421bd is not authorized to perform: codepipeline:PollForJobs on resource: arn:aws:codepipeline:us-west-2:994238729631:actiontype:Custom/Build/JenkinsThu/1 (Service: AWSCodePipeline; Status Code: 400; Error Code: AccessDeniedException;

I had to manually add AWSCodePipelineFullAccess to the JenkinsRole. CF stack deletion failed because I did not

--

Jenkins EC2 instance has an IAM role granting access to CodePipeline.

How does CodePipeline have access to Jenkins?

I read create a job worker. It looks like the job worker (Jenkins, I think) always polls CodePipeline for requests for the job worker's actions, then it executes the action and informs CodePipeline. This might obviate the need for CodePipeline to authenticate into Jenkins.

craigwongva commented 6 years ago

Timeouts mentions inability to abort a pipeline and offers a workaround: edit the pipeline and save it.

craigwongva commented 6 years ago

Actually CodePipeline with Jenkins is a better article than the article listed at the top of this issue (because it mentions CodePipeline, not CodeDeploy).

craigwongva commented 6 years ago
TMP=/tmp/install

cd /home/ec2-user &> $TMP-1000

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz" &> $TMP-1100

tar -zvxf jdk-8u151-linux-x64.tar.gz &> $TMP-1200

sudo cp -r jdk1.8.0_151 /usr/lib/jvm/jdk1.8.0_151  &> $TMP-1300

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key &> $TMP-1600
sudo touch /var/cache/jenkins &> $TMP-1660
sudo touch /var/log/jenkins &> $TMP-1670
sudo touch /var/lib/jenkins &> $TMP-1680
sudo yum install -y jenkins &> $TMP-1700
sudo cp /home/ec2-user/pfeiffer4building/etc-sysconfig-jenkins /etc/sysconfig/jenkins &> $TMP-1750
sudo service jenkins start &> $TMP-1800
sudo cp /var/lib/jenkins/secrets/initialAdminPassword /tmp/ &> $TMP-1810