[英]How to Create a VM on GCP using Jenkins Pipeline
I tried to create a VM using gcloud directly in pipeline with this command,我尝试使用此命令直接在管道中使用 gcloud 创建一个 VM,
pipeline {管道{
agent any
stages{
stage('Create a VM'){
gcloud compute instances create centos-7 --image-family=centos-7 --image-project=centos-cloud --zone=europe-west2-c
}
}
}
I tried passing auth-key but not finding the correct syntax to do it, can anyone help?我尝试传递 auth-key 但没有找到正确的语法来做到这一点,有人可以帮忙吗?
The syntax is a next, even though there are a bunch of other steps to follow to achieve the connection and be able to create the machine, please follow this guide Using Jenkins for distributed builds on Compute Engine , which among such mentioned step we will show you a code example:语法是下一个,即使有很多其他步骤可以实现连接并能够创建机器,请按照本指南使用 Jenkins 在 Compute Engine 上进行分布式构建,在提到的这些步骤中,我们将展示你一个代码示例:
export PROJECT=$(gcloud info --format='value(config.project)')
cat > jenkins-agent.json <<EOF
{
"builders": [
{
"type": "googlecompute",
"project_id": "$PROJECT",
"source_image_family": "ubuntu-2004-lts",
"source_image_project_id": "ubuntu-os-cloud",
"zone": "us-central1-a",
"disk_size": "10",
"image_name": "jenkins-agent-{{timestamp}}",
"image_family": "jenkins-agent",
"ssh_username": "ubuntu"
}
],
"provisioners": [
{
"type": "shell",
"inline": ["sudo apt-get update && sudo apt-get install -y default-jdk"]
}
]
}
EOF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.