exp 4
sudo apt update
sudo apt upgrade -y
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
# Maven Project: https://github.com/devops-ds/your-maven-project.git
#Gradle Project: https://github.com/devops-ds/your-gradle-project.git
sudo apt update
sudo apt install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins
# in web browser login to jenkin with the administrator credentials you created during the initial setup.
#On the Jenkins dashboard, click "New Item" (or "Create a job" if it's a fresh installation).
#Enter an item name (e.g.,
Maven-GitHub-Freestyle or Gradle-GitHub-Freestyle).#Select "Freestyle project".
#Click "OK".
/ * In the job configuration page for your Freestyle project:
- Scroll down to the "Source Code Management" section.
- Select "Git".
- In the "Repository URL" field, enter the URL for your chosen GitHub repository (either one of the examples provided or your own).
- For Maven:
https://github.com/devops-ds/your-maven-project.git - For Gradle:
https://github.com/devops-ds/your-gradle-project.git
- For Maven:
- If you are using your own private repository, you will need to add credentials. Click "Add" next to "Credentials" and provide your GitHub username and password or a personal access token. If using the provided public repositories, no credentials are needed.
- Under "Branches to build", ensure
*/mainis specified. If your repository uses a different default branch (like*/master), adjust this accordingly. For the provided public repositories,*/mainis correct
- If you are building a Maven Project:
-
Scroll down to the "Build" section.
-
Click "Add build step".
-
Select "Execute shell" (or "Execute Windows batch command" on Windows).
-
In the "Command" area, enter the full path to your Maven executable followed by the goals you want to run (e.g.,
clean install).To find the full path to your
mvnexecutable on open terminal in Ubuntu and run:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword # terminal
#/path/to/your/maven/bin/mvn clean install
# Example:
/usr/bin/mvn clean install
Comments
Post a Comment